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

Tutorials and other help

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 vi commands mentioned in class, and some other useful ones. 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.