How do I create a mapping that works only in visual mode?

You can create mappings that work only in specific modes (normal, command, insert, visual, etc). To create a mapping that works only in the visual mode, use the “:vmap” command:

    :vmap  

This mapping will work in visual and select mode. If you want the map to work only in visual mode (excluding select mode), use:

    :xmap  

and to have the mapping only work in select mode (but not visual mode), use:

    :smap  

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind