• vim中SnipMate 和 YouCompleteMe 插件触发键 tab 冲突


    花了好几天废了九牛二虎之力终于在win下把ycm插件装上了

    然而在配置插件的时候发现snipmate插件与youcompleteme插件会发生tab键冲突

    而ycm比较调,直接使snipmate插件完全失效了

    在vim中执行以下代码

    :scriptnames

    发现snipmate插件是正常加载的

    那就可能是发生了键冲突

    先在vimrc中修改ycm的触发键试试

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

    然而并不行,应该还是是ycm干的。ycm你真流氓,自己都不用tab键了,还不让释放出来让别人用。。。

    那么试试修改snipmate

    按照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.

  • 相关阅读:
    Sql Server数据库快照初探
    RestTemplate的exchange()方法,解决put和delete请求拿不到返回值的问题
    常用 HTTP 状态码
    RestTemplate进行访问分页PageInfo
    Java RestTemplate传递参数
    SQL-----数据库三种删除方式详解
    Mybatis异常-java.lang.IllegalArgumentException: invalid comparison:java.util.Date and java.lang.String
    SpringBoot 项目不加载 application.properties 配置文件
    git设置、查看、取消代理
    Layui:select下拉框回显
  • 原文地址:https://www.cnblogs.com/acbingo/p/4751092.html
Copyright © 2020-2023  润新知