In Vim, how to find out what a key combination does

I accidentally press a shorcut key, and I know that vim has done something but I don't know what.

How can I find out what that shortcut key does?


Solution 1:

There are two potential sources for information. First of all, if it's a built in shortcut, it is normally in the help documentation. For instance, if you do :help CTRL-I, it'll take you to a help entry about moving around your jump list.

It is possible, however, that you have a custom mapping from one of your .vimrc files or an underdocumented plugin. In that case, try using :map which will list all custom keyboard mappings that are currently active. That will give you three columns:

  1. the mode the mapping applies to
  2. the keyboard shortcut
  3. the command that is run

You can then use :help to further investigate the command that is run.

Solution 2:

Just doing :map will show you lots of mappings, but if your mapping is F2 or ShiftEnter or CtrlP then the second column (which should show the keyboard shortcut) will be empty.

However you can ask map to tell you what a particular key combination is. Some examples that line up with the above examples:

:map <F2>
:map <S-CR>
:map <C-P>