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


Book HomeLinux in a NutshellSearch this book

11.3. ex Command-Line Options

While most people know ex commands only by their use within vi, the editor exists also as a separate program and can be invoked from the shell (for instance, to edit files as part of a script). Within ex, you can enter the vi or visual command to start vi. Similarly, within vi, you can enter Q to quit the vi editor and enter ex.

If you invoke ex as a standalone editor, you can include the following options:

+[num]

Start editing at line number num, or the last line of the file if num is omitted.

+/pattern

Start editing at the first line matching pattern. (Fails if nowrapscan is set in your .exrc start-up file.)

-c command

Run the given ex command upon start-up. Only one -c option is permitted. An older form of this option, +command, is still supported.

-e

Run as a line editor rather than full-screen vi mode (default).

-l

Enter LISP mode for running LISP programs (not supported in all versions).

-r [file]

Recover and resume editing on file after an aborted editor session or system crash. Without file, list files available for recovery.

-s

Silent; do not display prompts. Useful when running a script. This behavior also can be set through the older - option.

-t tag

Edit the file containing tag and position the cursor at its definition (see ctags in Chapter 3, "Linux Commands" for more information).

-v

Run in full-screen mode (same as invoking vi).

-w rows

Set the window size so rows lines at a time are displayed; useful when editing by a slow dial-up line.

-x

Prompt for a key that will be used to try to encrypt or decrypt a file using crypt (not supported in all versions).

-C

Same as -x, but assume the file is encrypted already (not supported in all versions).

-L

List files that were saved due to an editor of system crash (not supported in all versions).

-R

Edit files read-only; do not allow changes to be saved.

You can exit ex in several ways:

:x

Exit (save changes and quit).

:q!

Quit without saving changes.

:vi

Enter the vi editor.



Library Navigation Links

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