Sven [email protected] ©1995-2001

Last update: Thu Mar 29 12:00:00 MEST 2001

VIM Keys and Commands

This page was created to answer the frequently asked question "which key should I use to start my mappings?"

Well, it's a good idea to start mappings with a key that is not bound to a command by default; this avoids making mistakes. But all keys seem to be used for something! So - which key is not bound to a command?

Summary: The backslash key is not bound to a command by default. In fact, it is the *only* key which is not bound to a command by default.

However, the backslash is not easy to use on all keyboard types. Therefore I use the comma and the dot which happen to be on the same keys with many keyboards I use (German, English, US).

Please note that some keyboards offer keys for non-ASCII characters, eg the German keyboards which have "umlauts" (äöü). These are not considered here as mappings using such keys are not very portable due to the hard or even impossible usability; but you can certainly use them for mappings, of course.

Ralf Arens suggested using the keys TAB and DEL for command/normal mode - if you don't use them for other things, of course.

Anyway, a good overview on the key bindings is given in the helptext index.txt - have a look at it with ":help index"!

Note: In the following, a set of keys with a "similar function" is described here as a "class".

Keys and their "classification" as "motion command" or "text object". [According to "6. Cursor motions" of the helpfile (vim_ref.txt) of vim40.]


VIM Keys - Read This!

Some things you should know about editing with Vim:

Data as such never has a given meaning - it is always interpreted by programs and human beings. This holds for input via keyboards, too.

A letter, more generally a "character", that is sent from a keyboard by pressing a key does not always have the same meaning to a program, either. The interpretation of the input depends on the current mode/state of the receiving program, too, which may also have changed due to previous input.

So the description of a "command" usually requires a description of the current mode/state of the program as well. As this can get quite technical the description can also get quite long. Therefore most of the description is abbreviated by giving information about the assumed mode/state of the program before a set of related commands.

Related commands need to be defined with a relation. These relations are defined below. They will help you understand related commands and their use. Please read them, they should not be difficult to understand.

According to previous Keys as such are interpreted either as commands or input - this depends on the current mode and on previous input. In "normal mode" almost all the keys have an effect that either changes the text within the buffer of just moves the cursor.


Vim Keys - Terminology

bind
-> key binding

command
A command is the effect that a key will have on a command within the current mode/state.

key
A "key" usually is any data sent from a "keyboard". This is usually a "byte", ie a number with a value from zero to 255.
But then again, pressing a key on a keyboard can also send a "sequence of data". This often happens with arrow keys and functions keys once they are "bound". Unfortuntaley, these sequences vary from keyboard to keyboard. That's why there are always problems with the setup of those keys. VI tries to avoid this by making all commands available via standard keys that are available on every keyboard, namely the letters, digits, and punctuation.

key binding / bound/unbound
"Key binding" describes the feature of a program that allows "binding" any key to an arbitrary command of the program. This gives you the freedom to chose your favourite "command key set".

Vi and Vim use the term "mapping" instead. The definition of the effect This effect is described by a "command". A key is "bound" to a command either by a "mapping" or by default, ie without any .

map and mapping
VI uses "mapping" to -> "bind" a key to a -> "command". VI allows the user to "map" keys to "commands". More technically, the command "map" is a special "command sequence" of "command line mode" that allows to -> "bind" a -> "key"


VIM Keys - Key Classifications

A command falls into exactly one of the following classes:
'-' ("none") - free/unbound/undefined
No command is associated with the key by default.
VIM will simply beep when it is told to execute the (non-existent) command. Please note that due to the possibility to map a sequence of keys to a command Vim has to wait for a given timeout to allow possible completion of a command sequence. After this time has passed, Vim is able to check the input for a possible command sequence until the "timeout" passes to "know" that this it takes "a while" for Vim to realize that this key is not bound to a "command sequence" - Vim has to wait Thus these keys are "free" to be bound to a command. You are advised to use one of these keys to define mappings on as they will not take away a command that already exists.

'j' ("jump")
A "jump" key is a key that is bound to a "jump command" by default. A "jump command" does not change the text but only moves the cursor onto (another) position within the current buffer.
Jump commands command differ in the movement directions: backward/forward, left/right, up/down; "opposite" (to previous direction); and some special jumps that VIM defines via the commands that are initiated with the 'g' key (which is not used in Vi).

'c' ("change") - Text changing commands

's' ("scroll") - Change the range of lines shown in window


VIM Key Table

either is a movement of a certain direction Movement commands will take the cursor backward, forward, up or down, etc. The following "classes" a
- = not defined
Standard movement directions:
b = backward	<->	f = forward
l = left	<->	r = right
d = down	<->	u = up
Special movement directions:
a = again, ie same direction as previous one
o = opposite direction than previous
m = match/memorize (finds a match and thus moves either backward or forward)
s = scroll / reset current line
V = vim special motion    
X = extra - all keys that do not fit into one of the above classes

VIM Keys - Table

The "class" of each letter is given below the letter. Digits are used to describe a number for repetitions. meta letters set name - abcdefghijklmnopqrstuvwxyz small / lowercase letters cbccfrVlcdur--cc-ccrc-fc-- shift ABCDEFGHIJKLMNOPQRSTUVWXYZ capital/uppercase letters cbccflsucc-d*acc-cclc-fc-- control ABCDEFGHIJKLMNOPQRSTUVWXYZ control characters ss-sss-*md-X**mucccms---s- 033-047 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 key ! " # $ % & ' ( ) * + , - . / class X X b f m X m b f j f o n X f 048-057 digits 058-064 058 059 060 061 062 063 064 key : ; &lt; = &gt; ? @ class X a X X X b X 065-090 A-Z (capital / uppercase letters) 091-096 091 092 093 094 095 096 key [ \ ] ^ _ ` class X - X b f m 097-122 a-z (small / lowercase letters) 123-127 123 124 125 126 127 key { | } ~ del class b m f X - X = extra ASCII key function 033 ! pipe 034 " use following register name for next delete, put or yank 038 & repeat last substitution command 046 . repeat last command 058 : switch to ex command line mode 060 &lt; shift text leftwards 061 = filter lines through external command 062 &gt; shift text rightwards 064 @ execute contents of following register name 091 [ first char for jump command 093 ] first char for jump command 126 ~ switch case of current character

TODO

Describe command operators.
URL:         http://www.math.fu-berlin.de/~guckes/vim/keys.html
URL:         https://www.vim8.org/keys.html (mirror)
Created:     Tue Jun 18 00:00:00 MET 1996
Send feedback on this page to
Sven Guckes [email protected]