vi editor basics

Cursor movement
Forward one spacel,space or right arrow
backward one space h,backspace or left arrow
next line (beginning) + or RETURN
next line (same column) j, ^N or down arrow
previous linek,^P,up arrow
beginning of line^
end of line$
goto linelinenumber G (example: 45G)
next wordw,W (not identical commands)
previous wordb,B (not identical commands)
end of worde,E (not identical commands)
beginning of sentence(
end of sentence)
matching parenthesis,
bracket or brace
%
homeH
midscreenM
lower screenL
Screen Commands
scroll^U,^D
page^F,^B
redraw^L,^R
insert before cursori
append after cursora
open new line and inserto (below), O (above
Deletion
delete characterx
delete worddw
delete linedd
Modification
undo last changeu
repeat last insert
or delete command
.
overstrike new characterr new-character
overstrikeR new characters ESC
copy text into unnamed bufferyy
put text from unnamed bufferp
copy text into named buffer
examples
"ayy - yank one line into buffer a
5"byy - yank 5 lines into buffer b
put text from named buffer"ap
join linesJ
Searching
search forward/pattern/
search backward?pattern?
repeat last searchn (same direction), N (opposite direction)
I/O
write changes back to file:w
read in a file:r filename
quit:q
quit without changing file:q!
Command count examples
move 3 words forward3w
move 4 pages forward4^F
delete 6 lines6dd
Search and replace examples
replace all occurrences of
the string 'cat' by 'feline'
:g/cat/s//feline/g
replace any occurrence of 'cat'
at the beginning of a line
:g/^cat/s//feline/g
put a space at the beginning
of every line
:g/^/s// /g
replace each lower-case letter
by the same letter doubled
:g/[a-z]/s//&&/g
Editing several files
edit next file:n
rewind to first file in list:rew
edit a file out of order:e filename
find out where you are^g