
724
|
Chapter 9: The vi, ex, and vim Editors
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
You can exit ex in several ways:
:x Exit (save changes and quit).
:q! Quit without saving changes.
:vi Enter the vi editor.
Review of vi Operations
This section provides a review of the following:
• vi modes
• Syntax of vi commands
• Status-line commands
Command Mode
Once the file is opened, you are in command mode. From command mode, you
can:
• Invoke insert mode
• Issue editing commands
• Move the cursor to a different position in the file
• Invoke ex commands
• Invoke a Unix shell
• Save the current version of the file
• Exit vi
Insert Mode
In insert mode, you can enter new text in the file. You normally enter insert mode
with the i command. Press the Escape key to exit insert mode and return to
command mode. The full list of commands that enter insert mode is provided
later, in the section “Insert Commands.”
Syntax of vi Commands
In vi, editing commands have the following general form:
[n] operator [m] motion
The basic editing operators are:
c Begin a change.
d Begin a deletion.
y Begin a yank (or copy).
If the current line is the object of the operation, the motion 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. (For example, cf.