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

3/3/02

ABSTRACT

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.

1. Getting started 1.1. Specifying terminal type 1.2. Editing a file 1.3. The editor's copy: the buffer 1.4. Notational conventions 1.5. Arrow keys 1.6. Special characters: ESC, CR and DEL 1.7. Getting out of the editor

2. Moving around in the file 2.1. Scrolling and paging 2.2. Searching, goto, and previous context 2.3. Moving around on the screen 2.4. Moving within a line 2.5. Summary 2.6. View

3. Making simple changes 3.1. Inserting 3.2. Making small corrections 3.3. More corrections: operators 3.4. Operating on lines 3.5. Undoing 3.6. Summary

4. Moving about; rearranging and duplicating text 4.1. Low level character motions 4.2. Higher level text objects 4.3. Rearranging and duplicating text 4.4. Summary

5. High level commands 5.1. Writing, quitting, editing new files 5.2. Escaping to a shell 5.3. Marking and returning 5.4. Adjusting the screen

6. Special topics 6.1. Editing on slow terminals 6.2. Options, set, and editor startup files 6.3. Recovering lost lines 6.4. Recovering lost files 6.5. Continuous text input 6.6. Features for editing programs 6.7. Filtering portions of the buffer 6.8. Commands for editing LISP 6.9. Macros 6.10 Word Abbreviations 6.11 Abbreviations

7. Nitty-gritty details 7.1. Line representation in the display 7.2. Counts 7.3. More file manipulation commands 7.4. More about searching for strings 7.5. More about input mode 7.6. Upper case only terminals 7.7. Vi and ex 7.8. Open mode: vi on hardcopy terminals and glass tty's

Footnotes