vim: how to specify arrow keys

Vim

Vim Problem Overview


In vim, when using map commands you must specify keys. For example <CR> <ESC> <F1>. What are the corresponding ones for the arrow keys?

Vim Solutions


Solution 1 - Vim

If you don't know the internal code for a certain key, type CtrlK and then the function key. For example, this sequence followed by the up arrow key will output:

<Up>

You can learn more about this command in the documentation for both insert and command mode. The specific ways to map a special key are given in the documentation with the tag :map-special-keys. Additionally, you can find a handy table with :h key-notation.

Solution 2 - Vim

Quite literal:

<Left>
<Right>
<Up>
<Down>

As noted in the comments, find this and more in this tutorial.

Solution 3 - Vim

And

<C-Right>

for Control key and Right.

For example, I used the following mappings (in my .vimrc) to cycle through my open buffers:

nnoremap <silent> <C-Right> :bn<CR>
nnoremap <silent> <C-Left> :bp<CR>

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
QuestionSteven LuView Question on Stackoverflow
Solution 1 - VimsidyllView Answer on Stackoverflow
Solution 2 - Vimnumbers1311407View Answer on Stackoverflow
Solution 3 - VimRishadView Answer on Stackoverflow