A vi Reference Sheet

The vi (pronounced vee-eye) editor was developed by the University of California - Berkleley. While vi is a somewhat complex editor (virtually every key on the keyboard has a function), it is the one editor that you can be sure will be installed on a machine. With that said, it is a good idea to at least have a working knowledge of vi. To put yourself into command mode <Esc> needs to be pressed. This will allow you to execute the following commands.

Running vi
vi filename opens filename in vi. If the file does not exist vi creates it.
Entering Text
i Start inserting at the cursor position. All characters typed will be inserted until <Esc> is pressed.
a Start appending text after the cursor position. All characters typed are inserted until <Esc> is pressed.
Moving Cursor
h, j, k, l Moves cursor, left, down, up, and right. The arrow keys *may* work on some systems.
$ Move cursor to the end of the current line.
:1 Go to line 1. Entering another number in place of 1 will bring you to that line instead.
:$ Go to ther last line.
 Other Commands
dd Delete the line the cursor is on.
x Delete the character the cursor is on.
p, P Paste the last deleted text at or after the cursor position
u Undo the previous command.
U Undo changes to the current line.
J Join the following line to the end of the current line. 
<control> - L Re-paint your screen. 
? help
Saving and Exiting 
:q! Abandon ALL changes and exit vi.
:w  save and return to vi
ZZ
:wq
save all changes and exists vi.