Chapter 8. The vi EditorContents:
Review of vi Operations This chapter presents the following topics:
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. 8.1. Review of vi OperationsThis section provides a review of the following:
8.1.1. Command-Line SyntaxThe 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 ModeOnce the file is opened, you are in command mode. From command mode, you can:
8.1.3. Insert ModeIn insert mode, you can enter new text in the file. Press the Escape key to exit insert mode and return to command mode. The following commands invoke insert mode:
8.1.4. Syntax of vi CommandsIn vi, commands have the following general form: [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.4.1. Examples
8.1.5. Status-Line CommandsMost 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. |
|