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:
This mapping will work in visual and select mode. If you want the map to work only in visual mode (excluding select mode), use:
and to have the mapping only work in select mode (but not visual mode), use: