Chapter 8. The vi Editor
vi is pronounced “vee eye.”
Besides the original Unix vi, there are a number of freely available vi clones. Both the original vi and the clones are covered in Learning the vi Editor, listed in the Bibliography.
This section provides a review of the following:
8.1.1. Command-Line Syntax
The three most common ways of starting a vi session are:
vi file vi +n file vi +/pattern file
You can open file for editing, optionally at line n or at the first line matching pattern. If no file is specified, vi opens with an empty buffer. See Chapter 2, for more information on command-line options for vi.
Note that vi and ex are actually the same program; thus it is worthwhile to review the material in Chapter 9, as well, in order to become familiar with the ex command set.
8.1.2. Command Mode
8.1.3. Insert Mode
8.1.4. Syntax of vi Commands
[n] operator [m] object
The basic editing operators are:
If the current line is the object of the operation, the object is the same as the operator: cc, dd, yy. Otherwise, the editing operators act on objects specified by cursor-movement commands or pattern-matching commands. n and m are the number of times the operation is performed, or the number of objects the operation is performed on. If both n and m are specified, the effect is n × m.
An object can represent any of the following text blocks:
8.1.5. Status-Line Commands
Most commands are not echoed on the screen as you input them. However, the status line at the bottom of the screen is used to echo input for these commands:
Commands that are input on the status line must be entered by pressing the Return key. In addition, error messages and output from the CTRL-G command are displayed on the status line.
Copyright © 2003 O'Reilly & Associates. All rights reserved.