Basic Vi Keystrokes

Vi is an old but powerful editor available on essentially all Unix systems. It is actually the visual mode of an even older line editor, ex. Because of its age, vi does not directly use a mouse.

The most important thing to realize about vi is that it has two modes, command and insert. Whenever you are in doubt about which mode you are in, hit the escape key - that will get you into command mode. Command mode is right for moving about a file, copying or deleting a line, saving a file, etc. While in insert mode the text you type is actually entered in the file.

Whenever you are in doubt, hit the escape key and you will be in command mode. That's also the mode you are in when you start editing, e.g. by typing vi filename. You enter insert mode by typing i or one of the other commands listed below.

Most commands can be repeated by prefacing them with a number; for example typing 5j in command mode will move the cursor down 5 lines.

Motion Keys

(These are for moving the cursor around.)

Insertion Commands

Deletion Commands

Pasting

Miscellaneous

Saving and Quitting

Searching

Last Update: September 20, 1998