Search code examples
vimmappings

VIM: mapping for visual line mode


I have this mappings for indenting several lines by pressing TAB in visual mode:

vnoremap <Tab> >gv
vnoremap <S-Tab> <gv

But it conflicts with snipmate plugin. Is there a way to remap TAB button to work only in visual line mode (S-V)?


Solution

  • Change your mapping commands from vnoremap to xnoremap:

    xnoremap <Tab> >gv
    xnoremap <S-Tab> <gv
    

    Why?

    v[nore]map defines mappings both for visual mode and for select mode. Because Snipmate puts you into select mode when you are on a placeholder you need to use a more specific mapping command that can't be triggered in select mode: x[nore]map.

    Actually, you should always use x[nore]map instead of v[nore]map.