STARTING vi
vi filename edit a file named "filename"
vi newfile
create a new file named "newfile"
ENTERING TEXT
i
a
insert text left of cursor
append text right of cursor
MOVING THE CURSOR
h
j
k
l
left one space
down one line
up one line
right one space
BASIC EDITING
x
nx
X
dw
ndw
dd
ndd
D
r
cw
ncw
C
o
O
J
nJ
u
U
delete character
delete n characters
delete character before cursor
delete word
delete n words
delete line
delete n lines
delete characters from cursor to end of line
replace character under cursor
replace a word
replace n words
change text from cursor to end of line
insert blank line below cursor
(ready for insertion)
insert blank line above cursor
(ready for insertion)
join succeeding line to current cursor line
join n succeeding lines to current cursor line
undo last change
restore current line
MOVING AROUND IN A FILE
w
b
$
0 (zero)
H
M
L
G
1G
forward word by word
backward word by word
to end of line
to beginning of line
to top line of screen
to middle line of screen
to last line of screen
to last line of file
to first line of file
<Control>f scroll forward one screen
<Control>b scroll backward one screen
<Control>d scroll down one-half screen
<Control>u scroll up one-half screen
n
repeat last search in same direction
N
repeat last search in opposite direction
CLOSING AND SAVING A FILE
ZZ
:w
:q!
save file and then quit
save file
discard changes and quit file