vim

How to find unmapped control keys in vim?


I would like to do something like

map <C-k> :e#<CR>

in my .vimrc.

However, I recently found that <C-k> is used for digraphs.

How do I get a list of unmapped control keys in vim?


Solution

  • Vim has many commands, so it can be a challenge to find a (memorable and short) key sequence for mappings.

    My approach is to use the recommended <Leader> prefix for things I do not use frequently, but for essential stuff a mapping with Ctrl is useful, indeed.

    Learn how the commands are represented in the help (e.g. CTRL-O in normal mode, i_CTRL-X_CTRL-N for insert mode), think of a good mapping candidate, then try to look it up via :help CTRL-k) If there are no matches, you can make sure that the mapping is free via :nmap <C-k>; if there is a match (the nice thing is that this also covers plugins that supply documentation), you can read the description, have at least discovered a new Vim command, and can then decide whether you need it (then retry with a different mapping candidate), or whether you override the command.

    (Note that you can also :noremap built-in commands to other keys, but be aware that this makes you increasingly helpless in vanilla Vim installations or other application's vi-emulation modes.)