FiveFeet
Entering And Leaving VI			File Manipulation
-----------------------			-----------------
%vi name	edit name at top	:w 	   write back changes
%vi +n name	... at line n		:wq	   write and quit
%vi + name	... at end		:q	   quit
%vi -r		list saved files	:q!	   quit, discard changes
%vi -r name	recover file name	:e name	   edit file name
%vi name ...	edit first;rest via :n	:e!	   reedit discard changes
%vi -t tag	start at tag		:e + name  edit starting at end
%vi +/pat name	search for pat		:e +n name edit starting at line n
% view name	read only mode		:e #	   edit alternate file
ZZ		save and exit from vi	CTRl-^	   synonym for :e #
CTRL-Z		stop vi, don't exit	:r(name)   paste file name starting at
						   current position.
					:w(name)   write file name
The Display				:w! name   overwrite file name
-----------				:sh	   run shell, then return
					:!cmd	   run cmd, then return
Last line   Error mesg, echoing input	:n	   edit next file in arglist 
	    to :/? and !, feedback	:n args	   specify new arglist
	    about i/o and large changes	:f	   show current file and line
@ lines     On screen only, not in file	CTRL-G	   synonym for :f
~lines      Lines past end of file	:ta tag	   to tag file entry tag
CTRL-x      Control characters, DEL is	CTRL-]	   :ta, following word tag
	    delete.
tabs	    Expand to spaces, cursor
	    at last.

Vi Modes				Positioning within File
--------				-----------------------
Command	    Normal and initial state	CTRL-F     forward screenfull
	    Others return here. Esc	CTRL-B     backward screenfull
	    (escape) cancels partial	CTRL-D     scroll down half screen
	    command.			CTRL-U     scroll up half screen
Insert	    Entered by a i A I O	G	   goto line (end default)
	    o c C s S R. Arbitrary	/pattern   next line matching pattern
	    test then terminates	?pattern   prev line matching pattern
	    with ESC character, or	n	   repeat last / or ?
	    abnormally with interrupt	N	   reverse last / or ?
Last line   Reading input for :/? or !;	/pat/+n	   n'th line after pat
	    terminate with ESC or CR	?pat?-n	   n'th line befor pat
	    to execute. interrupt to	]]	   next section/function
m      	    cancel.			[[	   previous section/function
					%	   find matching () { or }

Counts Before Vi Commands		Adjusting the Screen
-------------------------		--------------------
line/column number		z G |	CTRL-L	   clear and redraw
scroLl half-page	CTRL-D CTRL-U	CTRL-R	   retype, eliminate @ lines
replicate insert	a i A I		z   redraw, at window top
repeat effect		most rest	z-	   ... at bottom
					z.	   ... at center
Simple Commands				/pat/z-	   pat line at bottom
---------------				zn.	   use 
					CTRL-E	   scroll window down 1 line
dw	    delete word			CTRL-Y	   scroll window up 1 line
de	    ... leave punct
dd	    delete a line		Corrections during Insert Mode
3dd	    ... 3 lines			------------------------------
i(text) ESC insert text (return 
	    to cmd mode)
cw(new) ESC  change word to new		CTRL-H	   erase last character
	     (return to cmd mode)
easESC	    pluralize word		CTRL-W	   erases last word
xp	    transpose characters 	erase	   your erase, same as CTRL-H
	    (switch current char 	Kill erase input this line 
	     w/ next)
Interrupting, Cancelling		\	   escapes CTRL-H, erase, kill
------------------------		ESC	   end insert, command mode
					CTRL-C	   interrupt, terminate insert
ESC	    end insert or command	CTRL-D	   backtab over autoindent
CTRL-C	    interrupt (or DEL)		CTRL-^D	   kill auto, save for next
CTRL-L	    refresh screen		0CTRL-D	   ... but at margin next also
					CTRL-V	   quote non-printing character

Marking and Returning			Insert and Replace
---------------------			------------------
``	    previous context		a	   append after cursor
''	    ... at first non-white	i	   insert before
	    in line			A	   append at end of line
mx	    mark position with 		I	   insert before first non-white
`x	    to mark x			o	   open line below
'x	    ... at first non-white	O	   open above
	    in line			rx	   replace single char with x
					R	   replace characters

Line Positioning			Operators (double to effect line)
----------------			---------------------------------

H	    top window line		dd	   delete line
L	    last window line		cc	   cut line to paste with p.
M	    middle window line		<	   left shift
+	    next line at first		>	   right shift
	    non-white			!	   filter through command
-	    previous line, at first	=	   indent for LISP
CR	    return, same as +		yy	   yank lines to buffer
down arrow				
or j	    next line, same column	Miscellaneous Operations
up arrow				------------------------
or k	    prev line, same column
					C	   change rest of line
Character Positioning			D	   delete rest of line
---------------------			s	   substitute chars
					S	   substitute lines
^	    beginning of Line.		J	   join lines
$	    end of line			X	   ... before cursor
right arrow				Y	   yank lines
or l	    forward			x	   delete characters
left arrow				Yank and Put
or h	    backwards			------------
CTRL-H	    same as left arrow
space	    same as right arrow		p	   put back lines
					(num)yy	   yank num lines 
					Undo,Redo,Retrieve
|	    to specified column		------------------
%	    find matching () or {}
					u	   undo last change
Words, Sentences, Paragraphs		U	   restore current line
----------------------------		.	   repeat last change
					(num)yy	   yank num lines 
w	    word forward
b	    back word (to first char) 	Commands for LISP
e	    to last character of W	-----------------
)	    to next sentence
}	    to next paragraph		)	   Forward s-expression
(	    back sentence		}	   ... but don't stop at atoms
{	    back paragraph		(	   back s-expression
W	    word forward		{	   ... but don't stop at
B	    back W (to first char)
E	    to last character of W	

Source