vim中SnipMate 和 YouCompleteMe 插件觸發鍵 tab 衝突

花了好幾天廢了九牛二虎之力終於在win下把ycm插件裝上了python

然而在配置插件的時候發現snipmate插件與youcompleteme插件會發生tab鍵衝突git

而ycm比較調,直接使snipmate插件徹底失效了github

在vim中執行如下代碼vim

:scriptnames

發現snipmate插件是正常加載的app

那就多是發生了鍵衝突測試

先在vimrc中修改ycm的觸發鍵試試ui

let g:ycm_key_list_select_completion = ['<c-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']

然而並不行,應該仍是是ycm乾的。ycm你真流氓,本身都不用tab鍵了,還不讓釋放出來讓別人用。。。this

那麼試試修改snipmatespa

按照snipmate的文檔,修改trigger key要改動snipmate.vim/after/plugin/snipMate.vim文件插件

例如將<tab>改成<C-\>能夠將下面兩行

" You can safely adjust these mappings to your preferences (as explained in
" :help snipMate-remap). ino <silent> <tab> <c-r>=TriggerSnippet()<cr> snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr> 

改成

ino <silent> <C-\> <c-r>=TriggerSnippet()<cr> snor <silent> <C-\> <esc>i<right><c-r>=TriggerSnippet()<cr> 

 

一樣不行。。。。

怒了。。。。不行老子不用ycm了,就當本身這幾天白折騰了!

百度出還有一款相似的插件,嗯。。試試看

https://github.com/SirVer/ultisnips

用vundle將snipmate刪掉

而後在vimrc中增長如下代碼

" Track the engine.
Plugin 'SirVer/ultisnips'

" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'

" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"

" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"

保存後從新打開vim

執行

:PluginInstall

會安裝兩個插件。安裝完後新建.cpp文件,測試main<tab>,it works!(若不起做用,請修改ycm的觸發鍵)

仍是ultisnips厲害啊。。

後來瞭解到snipmates在09年已經中止維護了,其小組後來加入了ultisnips中,既然有ultisnips,爲何還存在snipmates呢,由於ultisnips須要python支持

領完,做者是這樣回答的

Q: Should 「snipMate be deprecated in favour of UltiSnips」?A: No, because snipMate is VimL, and UltiSnips requires Python. Some people want to use snippets without having to install Vim with Python support. Yes – this sucks.One solution would be: Use snippets if they are good enough, but allow overriding them in UltiSnips. This would avoid most duplication while still serving most users. AFAIK there is a nested-placeholder branch for snipMate too. snipMate is still improved by Adnan Zafar. So maybe time is not ready to make a final decision yet.

相關文章
相關標籤/搜索