I've set the mapping keys as follows:
" Easy indent for code blocks
nmap <tab> v>
nmap <s-tab> v<
vmap <tab> >gv
vmap <s-tab> <gv
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!
You can change the default expand trigger to other key, but I think It's better to use maps as follow:
It works well for me.
What's more,
<Tab>
remove multi-line codes which you selected is a feature ofUltiSnips
. You can use selected text inUltiSnips
snippets. Have a look at here.Looking at UltiSnips documentation via
:h UltiSnips-triggers
says this:So set something like this in your ~/.vimrc` file:
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 viau
.For more help see: