vi quick command reference

Moving the Cursor

   Down one line			j, <return>, +
   Up one line				k, -
   Left one character			h, <ctrl-h>
   Right one character			l, <space>

   Beginning of current line		0, ^
   End of current line			$

   Forward one screen			<ctrl-f>
   Back one screen			<ctrl-b>

   Down half a screen			<ctrl-d>
   Up half a screen			<ctrl-j>

   Beginning of file			gg
   End of file				G

   Move cursor to specified line	line no. G

   Beginning of first screen line	H
   Beginning of last screen line	L
   Beginning of middle screen line	M

   Left to begining of word		b, B
   Right to end of word			e, E
   Right to beginning of word		w, W
   Beginning of next sentence		)
   Beginning of previous sentence	(

Creating Text

   Append text after cursor		a
   Append text after end of line	A

   Insert text before cursor		i
   Insert text at beginning of line	I

   Open new line after current line	o
   Open new line before current line	O

Modifying Text

   Change current word			cw, cW
   Change current line (cursor to end)	C

   Delete character (cursor forward)	x
   Delete character (before cursor)	X

   Delete word				dw, dW
   Delete line				dd
   Delete text to end of line		D, d$
   Join current line with next line	J

   Put buffer text after/below cursor	p
   Put buffer text before/above cursor	P

   Repeat last modification command	.
   Replace current character		r
   Replace text to end of line		R
   Substitute text for character	s

   Undo your previous command		u

   Transpose characters			xp

   Yank (copy) word into buffer		yw
   Yank (copy) current line into buffer	Y, yy
   yank 3 lines                         3yy
   yank 3 characters                    3yl

Saving, Quitting

   Quit (no changes made)		:q!
   Quit and save			:x, :wq, ZZ
   Save (write) to current file		:w
   Write to specified file		:w filename
   Force write to a file		:w! filename

Using ex Commands From Within vi

   Copy specified lines			:co, t
   Display line numbers			:set nu
   Disable display of line numbers	:set nonu
   Move lines after specified line	:m
   Read file in after specified line	:r filename
   Review current editor options	:set 
   Review editor options		:set all
   Set new editor option		:set option

Some useful set options for your ~/.exrc file:

   :set all		Display all Set options
   :set autoindent	Indent following lines to the indentation
		   	of previous line.
   :set ts=4		set tab stop to 4 char
   :set ignorecase	Ignore case during pattern matching.
   :set list		Show special characters in the file.
   :set number		Display line numbers.
   :set shiftwidth=n	Width for shifting operators << and >>
   :set showmode	Display when in Insert, Append, or Replace mode.
   :set wrapmargin=n	Set right margin 80-n for autowrapping lines 
			  (inserting newlines).  0 turns it off.

vi links: