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

Vim

Vim Problem Overview


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?

Vim Solutions


Solution 1 - Vim

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 - Vim

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>

Solution 3 - Vim

You might check out the answers at In Vim can I find out what keys I just typed? (If this is what you're looking for).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMcBear HoldenView Question on Stackoverflow
Solution 1 - VimConspicuous CompilerView Answer on Stackoverflow
Solution 2 - VimHamish DownerView Answer on Stackoverflow
Solution 3 - VimOwenView Answer on Stackoverflow