抱歉,我搜索了上述问题的答案,但没有一个符合我的确切情况。我是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的vim-snipmate存储库中给出的Pathogen指令安装了SnipMate(抱歉我不能发布两个以上的链接)而且看起来snipmate插件在vim中是活动的,因为当我这么做时{ {1}}我得到以下输出
:imap
所以根据上面的输出,当我进入快捷方式并按Ctrl + R时,snipmate会触发我,但它不起作用。但是,当我按下Ctrl + R + Tab时,我会看到一个片段列表,但是当我选择其中任何一个片段时它们都不起作用。例如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
中的cpp.snippets有一个类似
/home/username/.vim/bundle/vim-snippets/snippets/
当我按下Ctrl + R + Tab时,我会看到一个列表,其中我可以看到# for i
snippet fori
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4}
}
,但当我从列表中选择fori
时,它只显示为 fori 在我的vim文件中逐字逐句。我真的不确定还有什么可以让它发挥作用。我非常感谢让SnipMate与vim合作的任何帮助。
答案 0 :(得分:0)
所以我终于找到了问题,因为我安装了YouCompleteMe,其Tab函数与SnipMate的Tab函数冲突。我将Triger更改为现在似乎正常工作。