How to get the key name to be coded for keymap in vimrc?

To find out what a key or key combination outputs in Vim, I usually open a blank buffer with ":enew", enter insert mode, press control-v, then the key or key combination I want to identify. This control-v trick can also work on the :-command line, so defining mappings for testing is fairly easy. For example, ":map ", control-v and the key combination, " :echo 'it works'".


The closest I can find to describe-key (Ctrl+H, K) is the :map command. It will list all mappings.

You can also run :map <key name>, but you have to specify <key> using the special syntax listed in
key-notation.

Or you can try :mapCtrl+V<key>, which should let you just press the key rather than needing to use the special syntax.

So to bind Ctrl+Shift+V, try this:

:map <C-S-v> whatever

or

:mapCtrl+V Ctrl+Shift+V whatever

But make sure that your terminal program doesn't already use this for something special like paste, otherwise Vim will never see the key press.

Also see map-alt-keys, which helps explain whether your Alt key should be written as <M-x> or <A-x>.

Tags:

Vim

Keymap