An Introduction to
Display Editing with Vi

William Joy
Mark Horton

Computer Science Division
Department of Electrical Engineering and Computer Science
University of California, Berkeley
Berkeley, Ca. 94720

With Annotations by Gunnar Ritter
Freiburg i. Br., Germany


  Vi (visual) is a display oriented interactive text editor. When using vi the screen of your terminal acts as a window into the file which you are editing. Changes which you make to the file are reflected in what you see.

  Using vi you can insert new text any place in the file quite easily. Most of the commands to vi move the cursor around in the file. There are commands to move the cursor forward and backward in units of characters, words, sentences and paragraphs. A small set of operators, like d for delete and c for change, are combined with the motion commands to form operations such as delete word or change paragraph, in a simple and natural way. This regularity and the mnemonic assignment of commands to keys makes the editor command set easy to remember and to use.

  Vi will work on a large number of display terminals, and new terminals are easily driven after editing a terminal description file. While it is advantageous to have an intelligent terminal which can locally insert and delete lines and characters from the display, the editor will function quite well on dumb terminals over slow phone lines. The editor makes allowance for the low bandwidth in these situations and uses smaller window sizes and different display updating algorithms to make best use of the limited speed available.

  It is also possible to use the command set of vi on hardcopy terminals, storage tubes and “glass tty's” using a one line editing window; thus vi's command set is available on all terminals. The full command set of the more traditional, line oriented editor ex is available within vi; it is quite simple to switch between the two modes of editing.

  To preserve the practical use of this document as a vi introduction more than twenty years after its original creation, annotations have been made for this edition to reflect changes in the environment or in the editor itselves.

Table of Contents

  • Quick Reference Card

    Note: The text is often presented in eight sections. This is obviously result of a mistake and was thus corrected for this edition. When the subsection on Word Abbreviations was introduced for 4.0BSD in between the existing subsections on Macros and Abbreviations, it was labeled with a .NH macro instead of a .NH 2 one. But in troff -ms, .NH means the same as .NH 1, “start a numbered top level section”. So Word Abbreviations became the seventh section in print, and Nitty-gritty details the eighth one, breaking all existing references to the seventh section.