My vi "mug"
REMEMBER
^ move to first non blank in line
ctl-u, d up, down half screen, cursor stays put
ctl-e, y scroll screen up, down
H, L, M cursor to top, bottom, middle of screen
ctl-b, f back, forward one screen
mp mark p
`p move to p
d`p, y`p delete, copy text from mark to cursor
>>, << shift line in, out, modify w/ n
:set shiftwidth=2
:r !cmd run cmd and insert output
FILE COMMANDS
vi filename(s) edit a file or files
vi -r filename retrieve saved file
ZZ, :wq, :x save and exit
:q, :q! quit, quit without saving
:w, :w fn save file, save file as fn
:e filename edit file
:n open next file in list
:sh drop to new shell
:!cmd run command cmd
:r !cmd run cmd and insert output
:E filename split window and edit file
:W split window
ctl-w move between windows
SEARCH AND REPLACE
/txt, ?txt find txt forward, backward
/^txt find txt at beginning of line
n, N repeat last search forward, backward
r replace character
R replace/overwrite text from cursor
:s/txt/yyy substitute txt yyy current line
:%S/txt/yyy/g substitute txt yyy entire file, globaly
:.,$ current line to eof
:1,15 line 1 to 15
DELETING/INSERTING TEXT
CUT/COPY/PASTE
dw, dd, x delete word, line, character
ndw, ndd, nx delete n words, lines, characters
x, X delete character forward, backward
D, d$ delete to end of line
dG delete to end of file
dmotion, d-spc- delete from cursor to motion
nyy, nY copy n lines
yw copy word
ymotion copy from cursor to motion
y-space-, yl copy character under cursor
p, P paste text after, before cursor
a, i insert text after, before cursor
A, I insert text end, beginning of line
:>, :< shift line shiftwidth, in, out
>>, << same, modify w/ n
S replace text with blank line
o, O insert new line below, above
u, U undo last change, line change
. repeat last change
MOVING AROUND
all below can be modified w/ n-#, default is n=1
h, l, k, j left, right, up, down
b, w left, right beginning of word
e move to end of word
), ( move to next, previous sentence
}, { move to next, previous paragraph
% match brackets, parenthesis
nG move to line n
$, G move to end of line, file
0 move to beginning of line
^ move to first non blank in line
ctl-b, f back, forward one screen
ctl-u, d up, down one screen, cursor stays put
H, L, M cursor to top, bottom, middle of screen
ctl-e, y scroll screen up, down, cursor stays on line
WICKED COOL STUFF
~ change case
xp transpose characters
J join current with next line
:ab x y x is an abbreviation for y
mp mark p
`p move to p
d`p, y`p delete, copy text from mark to cursor
set noautoindent
set autoindent
set shiftwidth=2
set nu
set nonu