How to use vi (short for view, the standard Unix based text editor).

vi works in two modes, insert and command mode.  Insert mode is as
it sounds; its when you're just typing.  Command mode where you do file
command operations, or move around with cursor keys.  vi always starts
in "command mode," which is why you can't just start typing when  you
start it.  Escape will always return you to command mode.

---
Barebones.  This is all you need to struggle through vi life.

i: insert text where you are
ESC: stop typing text and go to command mode
x: delete one character
ZZ: after hitting escape, ZZ will save your file and exit vi.

---
How to get to insert mode:

i: insert text right where the cursor is
o: opens a new line below the cursor and lets you start inserting text
a: append text right after the cursor

you can also use variants of the above three:

I: inserts at the BEGINNING of the line, no matter where you are
O: opens a line ABOVE the current line to start typeing
A: starts appending at the END of the line

ESC: Escape will end your inserting and return you to command mode

---
Once in command mode, your basic operations are:

:w will write your file (or save it).  If you want you can pass it
  a parameter to write to another file (as in :w filename)
:q will quit (if you've made changes it will prompt you)
:q! will quit without saving and without a prompt to save
:w! will overwrite a file without prompting.
ZZ==the equivalent of :wq! (saves, then exits w/o prompting for anything).

---
More complex command mode operations include better ways to move around
files besides the arrow keys:

(these are important to know for repeditive commands...explained later)
h,l==left cursor, right cursor 
k,j==up cursor, down cursor

w/W: moves cursor ahead one word
b/B: moves cursor back one word
e/E: moves cursor to the END of the next word
#G: moves cursor to line # (1G to go to top, G by itself to go to the bottom)
L: goes to bottom of the screen
M: goes to the middle of the screen
H: goes to top of screen

ctrl-f: page down
ctrl-b: page up
ctrl-d: half page down
ctrl-u: half a page up
ctrl-y: exposes one more line at the top
ctrl-e: exposes one more line at the bottom

ctrl-l: refresh

---
Text modification through command mode:

cw: change the word you're on
cb: change previous word
C: change the entire line
r: replace one character
R: replace continually (overwrite)
s: replace current character with multiple characters
S: replace whole line with multiple characters

J: join the line you're on w/ the next line

x: delete the character the cursor is on
X: delete the character before the cursor (like a backspace)
dd: delete current line
D: delete to end of line
dG: delete to end of file
d#G: delete to line number #

yy: yank current line into temporary buffer (copy to buffer)

p: put.  When you delete or yank lines, they get copied to a buffer.
You can immediately put or paste them by manovering the cursor where
you want it and hitting p.

u: immedately undo whatever you just did.  
---
Repeating commands: any vi command can be iterated X number of times by
simply typing a number in front of the command letter.  For example:
3w: moves cursor ahead 3 words
10j: moves cursor down 10 lines
5dd: delete 5 lines
2yy: yank 2 lines

---
More advanced commands

~: changes the case of the current character
xp: transposes current and following character

/pattern: search down for pattern (uses Unix regular expressions)
?pattern: search up for pattern (uses Unix regular expressions)
n: find next existance of pattern
.: repeat the previous action
:r read in a file

sed commands: mass scale search and replace by pattern...very advanced.