The vi editor is one of the Unix text editing tools which goes back a long way. It's a very powerful editor, but that also means it can take quite a bit of time to learn and get used to.
There is actually a wikibook on the subject available at the Wikibooks site. It goes through how to use vi (usually one of its modern enhanced incarnations, like vim).
It goes through quite a lot, from the very basics to doing some pretty powerful stuff, although towards the end not all of the content is yet written. Nevertheless, it's an invaluable resource if you're thinking of learning how to use one of the most popular Unix text editors.
Here's a quick extract:
There are other ways to quit, e.g. pressing <Z><Z> (<Shift-z><Shift-z>) will save any unsaved work and quit the editor. Typing :wq will always save, even if there are no unsaved changes, and then quit the editor. :x will write if there are no unsaved changes, and it will quit. :wq and :x requires that you had previously provided a file name, so it will not work for the above simple example. Typing :q will quit if there have been no changes made; if changes have been made, vi will print a warning similar to "No write since last change".Don't worry
Many first time vi users stop at this point, and never touch vi again. If you tried to enter some text after you started, you will most likely have been greeted with a series of beeps and rather erratic behavior. Don't worry. This is perfectly normal for vi, and the editor is not broken. You will soon see why this is normal vi behaviour.