Dave's quick reference to using the "vim" text editor

Starting vim
Insert vs command mode
Saving and quitting
Insert commands
Other editing commands
Moving around the file
Search and replace
Screen appearance and vim options
Entering special characters
Macros: creating your own commands
Core commands for getting started with vim
sample configuration file: .vimrc to be placed in your home directory

Starting vim

If the system crashes or you lose connection while you're editing, you can usually recover what you were doing by typing
vim -r filename
Save the changes in the recovered file, quit, then remove the file named .filename.swp (so vim knows you've finished recovering).

Insert mode vs command mode:

Vi has two modes of operation: You will always be in one or the other, and if you look at the bottom of the screen you will see a status line that tells you when you're in INSERT mode.

Saving and quitting (from command mode)

Core commands: in the beginning you can probably get by with the i command for insert, the R command for replace, the dd command for deleting a line, and the ZZ command to save and quit. Just remember to that i and R put you in insert mode, so hit when you're ready to go back to command mode.
As you get comfortable with the basics, start experimenting with more and more of the options below to make your editing life easier. The % key to find matching brackets will be particularly handy when editing code.


Commands that take you into insert mode: (again, hit to get back to command mode)


Other editing commands available in command mode

When not inserting text, there are many commands available for manipulating the file contents:


Moving around in the file and repositioning things on the screen


Search and replace


Screen appearance options


Entering special characters

While in insert mode, the control-v sequence is useful to enter special characters in your text.


Macros: creating your own vim commands