Vi Crib sheet.
Mode
Command memonic Before/After Use
*** Leaving
:q quit c/- Quit (leaves vi).
*** Adding text.
i insert c/i Insert text before the cursor
a append c/i Insert text after the cursor
R replace c/i Overwrite text after the cursor.
o open-line c/i Insert new line below the cursor
O open-line c/i Insert new line above the cursor
<Esc> escape i/c Leave insert mode.
*** Saving
:w write c/c Write out file (save).
:w foo write c/c Write out file to foo (save as).
:e foo edit c/c Edit new file (named buffers are unaffected)
:e# edit last c/c Edit the previously open file.
*** Movement
k
h l Cursor keys c/c Move up donwn left right when in c mode
j
$ End c/c Move to end of line.
0 Home c/c Move to the start of the line.
^ Beginning c/c Move to the first charecter of the line.
1G Start c/c Move to the start of the document.
G Finish c/c Move to the end of the document.
44G Goto c/c Goto line 44
:44 Goto c/c Goto line 44
H top c/c Move to the top of screen.
L bottom c/c Move to the bottom of the screen
*** Searching
/<text> search c/c Search for text.
?<text> Back Search c/c Search backwards for text.
n next c/c next match on text.
N previous c/c previous match on text.
*** Copy, delete, paste.
dd delete line c/c Delete the current line (to buffer).
dw delete word c/c Delete current word.
d$ delete rest c/c Delete from cursor to end of line. (also D)
x delete char c/c Delete the charecter under the cursor
r replace char c/c Replace the charecter under the cursor
u Undo c/c Undo the last c
. Redo/Repeat c/c Redo the last c
yy yank line c/c Copy line to buffer.
y$ yank rest c/c Copy rest of line.
p paste c/c paste buffer.
"ayy named yank c/c yank to named buffer (a).
5"ayy multi yank c/c yank 5 lines to named buffer(a).
"ap named paste c/c paste from named buffer (a).