vi for the Forgetful
Invoking the Editor
vi filename Begin editing at first line
vi +n filename Begin editing at nth line
Getting out of Input Mode
ESC
Getting out of vi
:q!
:x Quit after saving changes
Adding Text (enter input mode)
i Insert text before cursor
a Insert text after cursor
A Append text to the current line
o Insert text on a new line after the current line
O Insert text on a new line before the current line
Deleting text
x Delete current character
nx Delete n characters
dd Delete current line
ndd Delete n lines
D Delete rest of line
Inserting a File
:r filename
Moving the Cursor Around
$ Move cursor to end of line
nG Move to the nth line
$G Move cursor to the end of the file
Searching
/ pattern Locate the given pattern
n Repeat the last search
Moving and Changing Text
nyy Yank n lines into a buffer
p Puts the buffer into the file after the cursor
P Puts the buffer into the file before the cursor
:s/old/new/ Substitute for one occurrence
:1,$s/old/new/g Substitute globally
:1,$s/old/new/gc Substitute globally and confirm substitutions
:e! Wipe out all editing changes