如何解决Vim中`UltiSnips`插件的TAB键映射的冲突 [英] How to solve the collision of TAB key mapping of `UltiSnips` plugin in the Vim

查看:410
本文介绍了如何解决Vim中`UltiSnips`插件的TAB键映射的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将映射键设置如下:

" Easy indent for code blocks
  nmap <tab>      v>
  nmap <s-tab>    v<
  vmap <tab>      >gv
  vmap <s-tab>    <gv

那很好.但是,当我通过vundle安装UltiSnips时,Tab键不能作为缩进操作使用,它将删除我选择的多行代码.我知道这是因为默认设置为UltiSnips.我想保留UltiSnips的Tab映射来触发其功能,如何解决使用TAB键缩进代码块的问题?谢谢!

That works good. But, when I installed UltiSnips by vundle, the Tab key does't work as indent action, it will remove multi-line codes which I selected. I know this is because the default setting of UltiSnips. I would like to remain the Tab mapping for UltiSnips to trigger its functions, How do I solve the problem of using the TAB key to indent code blocks? Thanks!

推荐答案

通过:h UltiSnips-triggers查看UltiSnips文档是这样的:

Looking at UltiSnips documentation via :h UltiSnips-triggers says this:

You can define the keys used to trigger UltiSnips actions by setting global
variables. Variables define the keys used to expand a snippet, jump forward
and jump backwards within a snippet, and list all available snippets in the
current expand context. The variables with their default values are: >
   g:UltiSnipsExpandTrigger               <tab>
   g:UltiSnipsListSnippets                <c-tab>
   g:UltiSnipsJumpForwardTrigger          <c-j>
   g:UltiSnipsJumpBackwardTrigger         <c-k>

因此,在您的〜/.vimrc`文件中设置以下内容:

So set something like this in your ~/.vimrc` file:

let g:UltiSnipsExpandTrigger = '<f5>'

但是,您可能需要重新考虑您的<tab>映射.我建议您删除它们,并在正常模式下使用>><<,在可视模式下使用><进行初始缩进/取消缩进,然后通过.(重做命令)重复该操作.如果您缩进/取消缩进太远,则可以通过u撤消它.

However you may want to reconsider your <tab> mappings. I suggest you remove them and use >> or << in normal mode and > or < in visual mode to do the initial indent/un-indent then repeat the action via ., the redo command. If you ever indent/un-indent too far then just undo it via u.

有关更多帮助,请参见:

For more help see:

:h >>
:h .
:h u

这篇关于如何解决Vim中`UltiSnips`插件的TAB键映射的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆