How to solve the collision of TAB key mapping of `UltiSnips` plugin in the Vim

谁说我不能喝 提交于 2019-12-05 05:53:56

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>

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

let g:UltiSnipsExpandTrigger = '<f5>'

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

You can change the default expand trigger to other key, but I think It's better to use maps as follow:

nnoremap > v>
nnoremap < v<
vnoremap > >gv
vnoremap < <gv

It works well for me.

What's more, <Tab> remove multi-line codes which you selected is a feature of UltiSnips. You can use selected text in UltiSnips snippets. Have a look at here.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!