
These keys are used for moving the cursor in normal mode. For example, you should not start your normal mode map key sequence with "j" or "k" or "l" or "h". You should not use a frequently used Vim key sequence at the start of your maps. You have to combine these key modifiers with other keys to create a map. Note that you cannot map the Shift or Alt or Ctrl keys alone as they are key modifiers. You can also prefix the desired key sequence with a backslash (\) or comma (,) or underscore (_), etc. Most of the key combinations should work in GUI Vim. But some of the key combinations may not work in all the terminal emulators. The function keys in combination with Control, Alt and Shift can also be used. Try to use an unused key sequence in your maps. For example, to list all the locations where maps beginning with "," are defined, use the following command: In the above command, replace with the desired key sequence. To determine the script or plugin that defines a map for a key sequence, use the following command.

To display the list of keys that are currently mapped, use the following commands: Some of the key sequences may be used by the existing Vim scripts and plugins. If you don't use some Vim functionality invoked by a particular key sequence or you have an alternate key sequence to use that functionality then you can use that key sequence in your maps. To get a list of the key sequences used by Vim, read the following help topic: If you use a key sequence in your map that is already used by Vim, then you will not be able to use the functionality provided by Vim for that key sequence. Many of the key sequences that you can enter from the keyboard are used by Vim to implement the various internal commands. In your private maps you should use key sequences that are not used by Vim and by other Vim plugins. Hence, typing Ctrl-v + Shift-Down_arrow will produce ^[[1 2B.Finding unused keys Further information: Unused keys To enter a terminal keycode in Vim, first type Ctrl-v, followed by the keystroke we want to obtain the term keycode from. Hence, typing Ctrl-v then Esc will produce ^[. To enter a literal character in Vim, first type Ctrl-v, followed by a single keystroke. Entering literal characters & terminal codes Įither in the :command line, or in insert mode: For this we need mappings (see section 2b).ġd. Shift-Down_arrow should now work, but the Ctrl-Shift-Down_arrow keycode can not be set in the same way. Once the correct terminal keycode is assigned to the appropriate Vim keycode, the keystroke should work in terminal Vim.

The following is not allowed because the keycode is not a listed Vim keycode: Where ^[ is a literal ESC special character. For example, to manually set the keycode for Shift-Down_arrow: The only difference is that we can :set internal keycodes. They are easy to read, quite intuitive, and are almost treated the same by Vim. Vim keycodes look a lot like the keystrokes we would define in a mapping. More on this later in section 2b.īe careful when setting these keycodes.

We can use this to our advantage to create more "responsive" mappings. In addition to the Vim keycodes listed in the help section above, the keycodes for the function keys actually go up to F37. Enter :set termcap to list the terminal keycodes (see :help terminal-options).
#Mapping the mac delete key in vim manual
To obtain a list of terminal keycodes, look it up in the manual for that terminal.įor a list of Vim's internal keycodes, see :help t_ku. Vim can act upon its own keycodes, and leave the assignment of terminal keycodes to autodetection (or to manual setup by the user, which is what this guide is for). Vim needs its own representation of keycodes because it runs on a variety of platforms. These are actual bytes that are sent to Vim by the terminal when we type Shift-Up, for example (on an xterm). Terminal keycodes look something likeĪnd press any keys. There are two types of keycodes: terminal keycodes and Vim keycodes.

Entering literal characters & terminal codes
