I am a newbie to Macs but I am familiar with Unix/Linux and vi so here you go.
esc is used to come out of insert mode.
If you don't hit it you will keep typing .
i is used to insert text.
Here is a list of vi commands for UNIX
http://www.cs.rit.edu/~cslab/vi.html
Among the most useful are
:w
:q
u- very useful indeed, Undo last action.