home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeBook TitleSearch this book

Chapter 9. The ex Editor

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. In vi, ex commands are preceded by a colon and entered by pressing Return.

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.

This chapter presents the following topics:

For more information, see Learning the vi Editor, listed in the Bibliography.

9.1. 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. Enter the command by pressing the Return 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 Section 9.2.

You can exit ex in several ways:

:x
Exit (save changes and quit).

:q!
Quit without saving changes.

:vi
Switch to the vi editor on the current file.

9.1.3. Options

!
Indicates a variant form of the command, overriding the normal behavior.

count
The number of times the command is to be repeated. Unlike in vi commands, count cannot precede the command, because a number preceding an ex command is treated as a line address. For example, d3 deletes three lines beginning with the current line; 3d deletes line 3.

file
The name of a file that is affected by the command. % stands for the current file; # stands for the previous file.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.