vi Keys

This section is a quick reference of many common vi commands. Some of these were discussed earlier in the chapter, while many will be new.

Table 15-1. Movement

OperationKey
left, down, up, righth, j, k, l
To the end of the line$
To the beginning of the line^
To the end of the fileG
To the beginning of the file:1
To line 47:47

Table 15-2. Editing

OperationKey
Removing a linedd
Removing five lines5dd
Replacing a characterr
Removing a characterx
Removing ten characters10x
Undo last actionu
Join current and next linesJ

Table 15-3. Searching

OperationKey
Search for “asdf”/asdf
Search backwards for “asdf”?asdf
Repeat last search forwards/
Repeat last search backwards?

Table 15-4. Saving and Quitting

OperationKey
Quit:q
Quit without saving:q!
Write and quit:wq
Write, without quitting:w
Reload currently open file:e!
Write buffer to file asdf:w asdf
Open file hejaz:e hejaz
Read file asdf into buffer:r asdf
Read output of ls into buffer:r !ls