Manual Page Result
0
Command: ex | Section: 1 | Source: UNIX v7 | File: ex.1
EX(UCB) EX(UCB)
NAME
ex - text editor
SYNOPSIS
ex [ - ] [ -v ] [ -t tag ] [ -r ] [ +lineno ] name ...
DESCRIPTION
Ex is the root of a family of editors: edit, ex and vi. Ex is a super-
set of ed, with the most notable extension being a display editing fa-
cility. Display based editing is the focus of vi.
If you have not used ed, or are a casual user, you will find that the
editor edit is convenient for you. It avoids some of the complexities
of ex 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(UCB), which is a command which focuses on the dis-
play editing portion of ex.
DOCUMENTATION
For edit and ex see the Ex/edit command summary - Version 2.0. The
document Edit: A tutorial provides a comprehensive introduction to edit
assuming no previous knowledge of computers or the UNIX system.
The Ex Reference Manual - Version 2.0 is a comprehensive and complete
manual for the command mode features of ex, but you cannot learn to use
the editor by reading it. For an introduction to more advanced forms
of editing using the command mode of ex see the editing documents writ-
ten by Brian Kernighan for the editor ed; the material in the introduc-
tory and advanced documents works also with ex.
An Introduction to Display Editing with Vi introduces the display edi-
tor vi and provides reference material on vi. The Vi Quick Reference
card summarizes the commands of vi in a useful, functional way, and is
useful with the Introduction.
FOR ED USERS
If you have used ed you will find that ex has a number of new features
useful on CRT terminals. Intelligent terminals and high speed termi-
nals are very pleasant to use with vi. Generally, the editor uses far
more of the capabilities of terminals than ed does, and uses the termi-
nal capability data base termcap(UCB) 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 editor makes use of features such
as insert and delete character and line in its visual command (which
can be abbreviated vi) and which is the central mode of editing when
using vi(UCB). There is also an interline editing open (o) command
which works on all terminals.
Ex contains a number of new features for easily viewing the text of the
file. The z command gives easy access to windows of text. Hitting ^D
causes the editor to scroll a half-window of text and is more useful
for quickly stepping through a file than just hitting return. Of
course, the screen oriented visual mode gives constant access to edit-
ing context.
Ex gives you more help when you make mistakes. The undo (u) command
allows you to reverse any single change which goes astray. 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 that it is easy
to detect when a command has affected more lines than it should have.
The editor also normally prevents overwriting existing files unless you
edited them so that you don't 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 editor 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 dealing with 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 deal with each in turn. The next command can also be
given a list of file names, or a pattern as used by the shell to spec-
ify a new set of files to be dealt with. 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 working on a large
program when you want to quickly find the definition of a particular
function. The command ctags(UCB) 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.
There is a command & in ex which repeats the last substitute command.
In addition there is a confirmed substitute command. You give a range
of substitutions to be done and the editor interactively asks whether
each substitution is desired.
You can use the substitute command in ex to systematically convert the
case of letters between upper and lower case. It is possible to ignore
case of letters in searches and substitutions. Ex also allows regular
expressions which match words to be constructed. This is convenient,
for example, in searching for the word ``edit'' if your document also
contains the word ``editor.''
Ex has a set of options which you can set to tailor it to your liking.
One option which is very useful is the autoindent option which allows
the editor to automatically supply leading white space to align text.
You can then use the ^D key as a backtab and space and tab forward to
align new code easily.
Miscellaneous new useful features include an intelligent join (j) com-
mand which supplies white space between joined lines automatically,
commands < and > which shift groups of lines, and the ability to filter
portions of the buffer through commands such as sort.
FILES
/usr/lib/ex2.0strings error messages
/usr/lib/ex2.0recover recover command
/usr/lib/ex2.0preserve preserve command
/etc/termcap describes capabilities of terminals
~/.exrc editor startup file
/tmp/Exnnnnn editor temporary
/tmp/Rxnnnnn named buffer temporary
/usr/preserve preservation directory
SEE ALSO
awk(1), ed(1), grep(1), sed(1), edit(UCB), grep(UCB), termcap(UCB),
vi(UCB)
AUTHOR
William Joy
BUGS
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 `-' op-
tion 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 ter-
minals 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 re-
sultant files.
UCB 4/4/79 EX(UCB)