EX(C) XENIX System V EX(C)
Name
ex - Invokes a text editor.
Syntax
ex [ - ] [ -v ] [ -t tag ] [ -r ] [ +lineno ] name ...
Description
ex is the root of the editors ex and vi. ex is a superset of
ed, whose most notable extension is a display editing
facility. Display based editing is the focus of vi.
If you have not used ed, or if you are a casual user, you
will find that edit is most convenient for you. It avoids
some of the complexities of ex which is used mostly by
systems programmers and persons very familiar with ed.
If you have a CRT terminal, you may wish to use a display
based editor; in this case see vi(C), a command which
focuses on the display editing portion of ex.
For ed Users
If you have used ed you will find that ex has a number of
new features. Intelligent terminals and high-speed terminals
are very pleasant to use with vi. Generally, the ex editor
uses far more of the capabilities of terminals than ed does.
It uses the terminal capability database termcap(M) and the
type of the terminal you are using from the variable TERM in
the environment to determine how to drive your terminal
efficiently. The ex editor makes use of features such as
insert and delete character and line in its visual command
mode, which can be abbreviated vi , which is the central
mode of editing when using vi(C). There is also an
interline editing open command, (o) that works on all
terminals.
ex contains a number of features for easily viewing the text
of a file. The z command gives easy access to windows of
text. Hitting Ctrl-D causes the editor to scroll a half-
window of text and is more useful for quickly stepping
through a file than just hitting the RETURN key. Of course,
the screen-oriented visual mode gives constant access to
editing context.
ex gives you more help when you make mistakes. The undo (u)
command allows you to reverse any single change. ex gives
you a lot of feedback, normally printing changed lines, and
indicates when more than a few lines are affected by a
command so it is easy to detect when a command has affected
more lines than it should have.
The editor also normally prevents the overwriting of
existing files unless you have edited them, so that you do
Page 1 (printed 8/7/87)
EX(C) XENIX System V EX(C)
not accidentally clobber with a write a file other than the
one you are editing. If the system (or editor) crashes, or
you accidentally hang up the phone, you can use the recover
command to retrieve your work. This will get you back to
within a few lines of where you left off.
ex has several features for editing more than one file at a
time. You can give it a list of files on the command line
and use the next (n) command to edit each in turn. You can
also give the next command a list of filenames, or a pattern
used by the shell to specify a new set of files to be
edited. In general, filenames in the editor may be formed
with full shell metasyntax. The metacharacter ``%'' is also
available in forming filenames and is replaced by the name
of the current file. For editing large groups of related
files, you can use ex's tag command to quickly locate
functions and other important points in any of the files.
This is useful when you want to find the definition of a
particular function in a large program. The command
ctags(CP) builds a tags file or a group of C programs.
For moving text between files and within a file, the editor
has a group of buffers named a through z. You can place text
in these named buffers and carry it over when you edit
another file.
The command & repeats the last substitute command. There is
also a confirmed substitute command. You give a range of
substitutions to be done and the editor interactively
prompts you whether each substitution is desired.
You can use the substitute command in ex to systematically
convert the case of letters between uppercase and lowercase.
It is possible to ignore case in searches and substitutions.
ex also allows regular expressions that match words to be
constructed. This is convenient, for example, when
searching for the word ``edit'' if your document also
contains the word ``editor.''
ex has a set of options that you can set. One option which
is very useful is the autoindent option that allows the
editor to automatically supply leading white space to align
text. You can then press Ctrl-D to backtab, space and tab
forward to align new code easily.
Miscellaneous new useful features include an intelligent
join (j) command which supplies whitespace between joined
lines automatically, the commands < and > which shift groups
of lines, and the ability to filter portions of the buffer
through commands such as sort.
Files
Page 2 (printed 8/7/87)
EX(C) XENIX System V EX(C)
/usr/lib/ex3.7strings Error messages
/usr/lib/ex3.7recover Recover command
/usr/lib/ex3.7preserve Preserve command
/etc/termcap Describes capabilities of terminals
$HOME/.exrc Editor startup file
/tmp/Exnnnnn Editor temporary
/tmp/Rxnnnnn Named buffer temporary
/usr/preserve Preservation directory
See Also
awk(C), ctags(CP), ed(C), grep(C), sed(C), termcap(M), vi(C)
Credit
This utility was developed at the University of California
at Berkeley and is used with permission.
Notes
The undo command causes all marks to be lost on lines
changed and then restored if the marked lines were changed.
Undo never clears the buffer modified condition.
The z command prints a number of logical rather than
physical lines. More than a screen full of output may
result if long lines are present.
File input/output errors don't print a name if the command
line ``-'' option is used.
There is no easy way to do a single scan ignoring case.
Because of the implementation of the arguments to next, only
512 bytes of argument list are allowed there.
The format of /etc/termcap and the large number of
capabilities of terminals used by the editor cause terminal
type setup to be rather slow.
The editor does not warn if text is placed in named buffers
and not used before exiting the editor.
Null characters are discarded in input files and cannot
appear in resultant files.
Page 3 (printed 8/7/87)