the three most essential commands in vi

i
from command mode puts you into 'insert' mode. You can add new letters, and back-space over stuff you do not want. If you can only backspace over things you have just added in this 'insert' session, you should go to command mode (hit esc) then type :set xxxxxxx . This is the default way of changing system wide defaults. You can append a list of these defaults such as :set number :set tab=4 in a file named .vimrc in your home directory. (see below)
esc
gets you back into command mode.
:wq
'w' will write the file (save it) 'q' quits vi and returns you to the command-line (a capital 'ZZ' with no colon from command mode will, do exactly the same as :wq)

the two most basic modes

now we are at what I find to be the first point of confusion.  There is command
mode and edit (insert) mode, I think that most of you have got that.  In
command mode you issue alot of commands on your file and we will get into
these, this is where we the coolest things exist in vi.  In insert mode all you
can do is add text, and erase (backspace over the text you have just added-if
you are runningin strict mode). 

In command mode there are commands you just type such as 'i', 'a', 'o', 'd',
'x''y' 'f' 't' (we are going to go over all of these and you should soon be
getting comfortable with them :)  There are also commands which must be
prefaced by the colon ':' such as we just saw :wq  often the commands which
must be prefaced by the colon include more typing such as ':set number' to turn
on line numbering or ':%s/.*/# &/' which will comment out every line in your
file (don't be afraid by the end of our time together that last one will look
like cake :) .

Most of the first commands you will learn which we are going to go over in this
lesson will not need to be prefaced by the colon except ':w' ':wq' or ':q'.

Try to remember if you wanted to do a 'save-as' save the buffer you are editing
under another name than the name under which it was opened. You could type from
command-mode ':w other-filename' this would save the buffer you are editing to
the file 'other-filename'  this is long ot type, hence you must preface it with
acolon.

Now what about the ':q'  if you have made changes to a file but don't want to
save them.  Vi will stop you "No write since last change" but that is what you
want, to quit with-out saving. So your brain races, your palms get sweaty, you
could type ':w trash' write the junk you have been editing to a file named
trash, which you will delete later, and then ':q' that would work (there is
always a solution right ? ) But luckily the writers of vi will save you a step
':q!' that's a 'q' for quit with an exclaimation point which says I mean it, or
yes you stupid program I know what I am doing, I don't want to save what I was
just typing.