CS 1320 (Principles of Algorithm Design I):
vi Hints and Tips

Versions/variants of vi

vi is available on just about every Unix system you will ever encounter, but it is a somewhat primitive editor. Newer and more capable variants exist. Two that are installed on the lab machines are:

Modes in vi

vi, unlike many editors, has two distinct "modes", and what happens when you press keys depends on which mode you are in. The modes are: Several commands put you into insert mode -- i, a, etc. The version of vi installed on the CS lab machines displays INSERT at the bottom of the screen if you are in insert mode. To get out of insert mode, press the ESC key.

If you try to type commands while in insert mode, the commands will just be entered in your file. Press the ESC key, delete the commands from your file, and try the commands again.

If you try to enter text while not in insert mode, the text will be interpreted as commands, often with surprising results. If this happens, first get out of insert mode if necessary and then use the "undo" command (u) repeatedly to clean up.

Useful commands

This is a list of the more basic standard vi commands. In the following: In typing a command, do not include the square brackets used to denote optional text. We assume you've started the editor with vimyfile.