vi Command Reference

This list was hastily put together for someone's own use and he thankfully shared it uponst the Internet many, many years ago.

Perhaps you'll find it useful as well.

Input Mode | Deletion and Change | Cursor Movement | Screen Movement | Last Line Mode | Miscellaneous

Input mode: set insertion point  [back to top]
i insert text at cursor
a append text after cursor
I insert text at beginning of line
A append text at end of line
o open line below cursor
O open line above cursor
Deletion and Change: delete/change words or characters  [back to top]
dw delete a single word
cw change a word
dd delete entire line
R replace line
D delete from cursor position to end of line
C change from cursor position to end of line
x delete a single character
r replace a character
Cursor movement: position the cursor  [back to top]
l move right
h move left
j move down
k move up
$ move to end of line
^ move to beginning of line
w move to next word
e move to end of word
1G move to first line
nG move to line n (where n is a number)
G move to last line
Screen movement: move a screen at a time  [back to top]
ctrl-d scroll forward half a screen
ctrl-u scroll back half a screen
ctrl-f move to next screen
ctrl-b move to previous screen
ctrl-l redraw screen
Last line mode: used when ending an editing session  [back to top]
:w write buffer
:q quit
:q! force quit without saving
:wq write and quit (save)
:n next file
:r read file
:e edit file
:f file name
:set set options on
:set no set options off
:! escape to shell
:n go to line n
Miscellaneous  [back to top]
u undo last action
/ search forward
? search back
n repeat search
. repeat last command
yy yank line
p put below cursor
P put above cursor
ZZ write and quit