0

抱歉,我搜索了上述问题的答案,但没有一个符合我的确切情况。我是 vim 的初学者,并试图将其设置为 C++ 编程。我正在使用 Xubuntu 14.04 并使用 sudo-apt 安装了 vim,我还使用以下命令安装了 YouCompleteMe 插件

apt-get install vim-youcompleteme
apt-get install vim-addon-manager
vam install youcompleteme

YouCompleteMe 完美运行,然后我通过简单地在链接http://www.vim.org/scripts/script.php?script_id=1658下载 zip 文件并将其解压缩到 ~/.vim 文件夹中来安装 NERDTree,NERDTree 也可以工作美好的。然后我使用链接https://github.com/tpope/vim-pathogen给出的说明为 vim 安装了病原体,我的 ~/.vimrc 看起来像

" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below.  If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
endif

execute pathogen#infect()

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
"  filetype plugin indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd     " Show (partial) command in status line.
set showmatch       " Show matching brackets.
set ignorecase      " Do case insensitive matching
set smartcase       " Do smart case matching
set incsearch       " Incremental search
set autowrite       " Automatically save before commands like :next and :make
set hidden      " Hide buffers when they are abandoned
set mouse=a     " Enable mouse usage (all modes)
set exrc

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

然后我使用 Garbas 在 vi​​m-snipmate 存储库中给出的 Pathogen 指令安装了 SnipMate(对不起,我不能发布两个以上的链接)而且看起来 snipmate 插件在 vim 中是活动的,因为当我这样做时,:imap我得到以下输出

i  <Nul>       * <C-X><C-O><C-P>
i  <Up>        * pumvisible() ? "\<C-P>" : "\<Up>"
i  <Down>      * pumvisible() ? "\<C-N>" : "\<Down>"
i  <S-Tab>     * pumvisible() ? "\<C-P>" : "\<S-Tab>"
i  <Plug>snipMateShow * <C-R>=snipMate#ShowAvailableSnips()<CR>
i  <Plug>snipMateBack * <C-R>=snipMate#BackwardsSnippet()<CR>
i  <Plug>snipMateTrigger * <C-R>=snipMate#TriggerSnippet(1)<CR>
i  <Plug>snipMateNextOrTrigger * <C-R>=snipMate#TriggerSnippet()<CR>
i  <Tab>       * pumvisible() ? "\<C-N>" : "\<Tab>"
i  <C-R><Tab>    <Plug>snipMateShow
Press ENTER or type command to continue

因此,根据上面的输出,当我输入快捷方式并按 Ctrl+R 时,snipmate 应该为我触发,但它不起作用。但是,当我按 Ctrl+R+Tab 时,我会看到一个片段列表,但是当我选择其中任何一个时它们都不起作用。例如 cpp.snippets in/home/username/.vim/bundle/vim-snippets/snippets/有一个类似的条目

# for i
snippet fori
    for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
        ${4}
    }

当我按 Ctrl+R+Tab 时,我会看到一个列表,我可以在其中看到fori,但是当我fori从列表中选择时,它只会在我的 vim 文件中逐字显示。我真的不确定还有什么可以让它发挥作用。我非常感谢任何帮助 SnipMate 使用 vim 的帮助。

4

1 回答 1

0

所以我终于弄清楚了这个问题,因为我让 YouCompleteMe 安装了它的 Tab 功能与 SnipMate 的 Tab 功能冲突。我将触发器更改为,它现在似乎可以工作了。

于 2015-07-29T17:12:24.090 回答