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

I set the display keys as follows:

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

It works well. But when I installed UltiSnips in a vundle, the Tab key does not work as an indent action, it will delete the multi-line codes that I selected. I know this because the default value is UltiSnips . I would like to leave the tab display for UltiSnips to call its functions. How to solve the problem of using the TAB key for indenting code? Thanks!

+6
source share
2 answers

The UltiSnips documentation through :h UltiSnips-triggers says the following:

 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 <cj> g:UltiSnipsJumpBackwardTrigger <ck> 

So, install something similar in the ~ / .vimrc` file:

 let g:UltiSnipsExpandTrigger = '<f5>' 

However, you can revise your <tab> mappings. I suggest you delete them and use >> or << in normal mode and > or < in visual mode to indent / non-indent, and then repeat the action with the command . , redo teams. If you ever retreated / retreated too far, just cancel it with u .

For more help see:

 :h >> :h . :hu 
+9
source

You can change the default extension trigger to a different key, but I think it's better to use cards like this:

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

This works well for me.

What's more, <Tab> delete the multi-line codes that you have selected is the UltiSnips feature. You can use the selected text in UltiSnips snippets. Take a look here .

0
source

Source: https://habr.com/ru/post/945318/


All Articles