
ex Basics | 739
vi
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
set sections=SeAhBhChDh nomesg " Set troff macros, disallow message
map q :w^M:n^M " Alias to move to next file
map v dwElp " Move a word
ab ORA O'Reilly Media, Inc. " Input shortcut
The q alias isn’t needed for vim, which has the :wn command. The
v alias would hide the vim command v, which enters character-at-a-
time visual-mode operation.
ex Basics
The ex line editor serves as the foundation for the screen editor vi. Commands in
ex work on the current line or on a range of lines in a file. Most often, you use ex
from within vi.Invi, ex commands are preceded by a colon and entered by
pressing Enter.
You can also invoke ex on its own—from the command line—just as you would
invoke vi. (You could execute an ex script this way.) You can also use the vi
command Q to quit the vi editor and enter ex.
Syntax of ex Commands
To enter an ex command from vi, type:
:[address] command [options]
An initial : indicates an ex command. As you type the command, it is echoed on
the status line. Execute the command by pressing the Enter key. address is the line
number or range of lines that are the object of command. options and addresses are
described below. ex commands are described in the next section “Alphabetical
Summary of ex Commands.”
You can exit ex in several ways:
:x Exit (save changes ...