ex(1)
_________________________________________________________________
ex Command
text editor
_________________________________________________________________
SYNTAX
ex [ - ] [ -v ] [ -t tag ] [ -r ] [ -R ] [ +command ] [ -l ] [ -x
] name ...
DESCRIPTION
Ex is the root of a family of editors: ex(1) and vi(1). Ex is a
superset of ed(1), with the most notable extension being a
display editing facility. Display-based editing is the focus of
vi.
If you have a CRT terminal, you may wish to use a display-based
editor; in this case see vi(1), 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 useful on CRT terminals, especially intelligent and
high-speed terminals. Generally, the editor uses far more of the
capabilities of terminals than ed does. It uses the terminal
capability data base (see terminfo(4)) and the type of the
terminal from the variable TERM in the environment to determine
how to drive your terminal efficiently. The editor uses 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(1).
Ex has a number of new features for easily viewing the text of
the file. The z command gives easy access to windows of text.
Typing ^D scrolls a half-window of text; this is more useful than
just pressing newline. 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 lets you 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. This makes it
easy to detect when a command has affected more lines than it
should have.
The editor also normally prevents overwriting existing files
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
ex(1)
unless you edited them so that you do not accidentally write over
a file other than the one you are editing. If the system (or
editor) crashes, or you accidentally hang up your modem
connection, 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 filenames, or a pattern as
used by the shell, to specify a new set of files to edit. 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 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.
It is possible to ignore case of letters in searches and
substitutions. Ex also lets you construct regular expressions
that match words. 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 that let you tailor it to your liking. A
very useful option is autoindent, which lets the editor
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)
command that supplies white space between joined lines
automatically, commands < and > that shift groups of lines, and
the ability to filter portions of the buffer through commands
such as sort (1).
INVOCATION OPTIONS
- Suppress all interactive-user feedback. This is
useful in processing editor scripts.
-v Invoke vi
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)
ex(1)
-t tag Edit the file containing the tag and position the
editor at its definition.
-r file Recover file after an editor or system crash. If
file is not specified a list of all saved files
will be printed.
+command Begin editing by executing the specified editor
search or positioning command.
-R Set readonly mode to prevent accidentally
overwriting the file.
-l LISP mode; indent appropriately for lisp code.
Also, the (), {}, [[, and ]] commands in vi are
modified to have meaning for lisp.
-x Encryption mode; create or edit an encrypted file.
You will be prompted for the encryption key. This
option is NOT available in international
distributions of the DG/UX System.
The name argument indicates files to be edited.
Ex States
Command The normal and initial state. Input is prompted
for by :. Your kill character cancels a partial
command.
Insert Entered by a, i, and c. Arbitrary text may be
entered. Insert is normally terminated by a line
having only . on it, or abnormally by an
interrupt.
Visual Entered by vi, terminated by Q or your quit
character.
Ex command names and abbreviations
abbreviate ab preserve pre version ve
append a print p visual vi
args ar put pu write w
change c quit q xit x,wq
chdir chd, cd>
copy co,t read r yank y
crypt cr, X
delete d recover rec window z
edit e rewind rew escape !
DG/UX 4.00 Page 3
Licensed material--property of copyright holder(s)
ex(1)
ex
file f set se lshift <
global g,v shell sh print next CR
join j stop st rshift >
list l substitute s scroll ^D
map suspend sy macro *,@
mark ma,k tag ta comment "
move m unabbreviate una current ______
next n undo u
number nu, # unmap unm
open O
NOTE:
For the following commands, only the abbreviations are
recognized; the command names are intended only as
descriptions:
window, escape, lshift, print next, resubstitutes, rshift,
scroll, macro, comment, and current.
Ex Command Addresses
n Line n /pat Next with pat
. Current ?pat Previous with pat
$ Last x-n n before x
x+n n after x
+ Next x,y x through y
- Previous 'x Marked with x
+n n forward '' Previous context
% 1,$
Initializing options
EXINIT Place commands in this environment variable
$HOME/.exrc Editor initialization file
./.exrc Editor initialization file
set x Enable option x
set nox Disable option x
set x=val Give value val to option x.
set Show changed options
set all Show all options
set x? Show value of option x
Most useful options and abbreviations
autoindent ai Supply indentation
autowrite aw Write before changing files
ignorecase ic Case-insensitive scanning
DG/UX 4.00 Page 4
Licensed material--property of copyright holder(s)
ex(1)
lisp ( ) and { } refer to s-exp's
list Print ^I for tab, $ at end of line
magic Enable metacharacters ., [ ], and *
number nu Number lines
paragraphs para Macro names that start paragraphs
redraw Simulate smart terminal
scroll Amount to scroll with ^D
sections sect Macro names that start sections
shiftwidth sw Amount to shift for < and >.
showmatch sm Match parentheses and braces.
showmode smd Show insert mode in vi
slowopen slow Stop updates during insert
window Amount to page with z.
wrapscan ws Scan entire file by wrapping.
wrapmargin wm Automatic line splitting
Scanning pattern formation
^ Beginning of line
$ End of line
. Any character
\< Beginning of word
\> End of word
[str] Any character in str
[^str] Any character not in str
[x-y] Any character between x and y
* Any number of the preceding character
_________________________________________________________________
EXAMPLES
$ ex testfile
:s/This/this
The above command shows the : for the ex prompt. The command
entered at the prompt will substitute the first occurrence of
"This" with "this" in the current line only.
:xit $ The above command will exit the ex editor. Changes are
saved, and the user is given the name of the file and the number
of lines in the file upon exiting. The shell prompt is returned.
_________________________________________________________________
DG/UX 4.00 Page 5
Licensed material--property of copyright holder(s)
ex(1)
AUTHOR
Vi and ex are based on software developed by the University of
California, Computer Science Division, Department of Electrical
Engineering and Computer Science, Berkeley California.
FILES
/usr/lib/exrecover Recover command
/usr/lib/expreserve Preserve command
/usr/lib/terminfo/?/* Terminal description files
$HOME/.exrc Personal editor startup file
./.exrc Local editor startup file
/tmp/Exnnnnn Editor temporary file
/tmp/Rxnnnnn Named buffer temporary file
/usr/preserve Preservation directory
SEE ALSO
awk(1), ed(1), edit(1), grep(1), sed(1), sort(1), vi(1),
curses(3X), term(5), terminfo(4) in the Programmer's Reference
for the DG/UX System
CAVEATS AND 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 screenful of output may result if long lines
are present.
File input/output errors do not print a name if the command line
- option is used.
There is no easy way to do a single scan ignoring case.
The editor does not warn if text is placed in named buffers and
then not used before exiting the editor.
Null characters are discarded in input files and cannot appear in
resultant files.
DG/UX 4.00 Page 6
Licensed material--property of copyright holder(s)