My condensed version of a cheat sheet for the vi editor.


:x     Exit, saving changes
:q     Exit as long as there have been no changes
ZZ     Exit and save changes if any have been made
:q!    Exit and ignore any changes

Inserting Text

i     Insert before cursor
I     Insert before line
a     Append after cursor
A     Append after line
o     Open a new line after current line
O     Open a new line before current line
r     Replace one character
R     Replace many characters


h     Move left
j     Move down
k     Move up
l     Move right

Deleting Text

Almost all deletion commands are performed by typing d followed by a motion.
For example, dw deletes a word.
A few other deletes are:

x     Delete character to the right of cursor
X     Delete character to the left of cursor
D     Delete to the end of the line
dd    Delete current line
:d    Delete current line