1BSD/exrefm/exrefm3.n

.if !\n(xx .so tmac.e
.SH
Modes
.PP
.Ex
has five distinct modes.
The primary mode is
.I command
mode.
Commands are entered in command mode when
a `:' prompt is present, and are executed each time a complete line is sent.
In
.I "text input"
mode
.I ex
gathers input lines and places them in the file.
The
.I append ,
.I insert ,
and
.I change
commands use text input mode.
No prompt is printed when you are in text input mode.
This mode is left by typing a `.' alone at the beginning of a line,
or by typing an end-of-file (\s-2CTRL\s0(D) at the beginning of a line.)
.PP
The last three related modes are
.I open
and
.I visual
modes,
entered by the commands of the same name,
and, within
.I open
and
.I visual ,
.I "text insertion"
mode.
.I Open
and
.I visual
mode allow local editing operations
to be performed on the text of a line.
.I Open
deals with one line at a time on soft-copy terminals
while
.I visual
works on
(unintelligent)
soft-copy terminals with full-screen addressible cursors.
.I Visual
uses the entire screen as a (single) window for file editing changes.
.br
.ne 10
.SH
Command structure
.PP
Most commands have alphabetic names,
and initial prefixes of the names are accepted.
The ambiguity of short names is resolved in favor of the more commonly
used commands,
always those of the editor
.ED .
Thus the command 
.I print
can be abbreviated `p'
while the shortest available abbreviation for the 
.I preserve
command is `pre'.
.PP
Most commands accept prefix addresses specifying the lines in the file
upon which they are to have effect.
The forms of these addresses will be discussed below.
A number of commands also may take a trailing
.I count
specifying the number of lines to be involved in the command.
Thus the command `10p' will print the tenth line in the buffer while
`delete 5' will delete five lines from the buffer,
starting with the current line.
.PP
Some commands take other information or parameters,
this information always being given after the command name.
Examples would be option names in a
.I set
command i.e. `set number',
a file name in an
.I edit
command,
a regular expression in a
.I substitute
command,
or a target address for a
.I copy
command, i.e. `1,5 copy 25'.
.SH
Feedback
.PP
Most commands which change the contents of the editor buffer give
feedback if the scope of the change exceeds a threshold given by the
.I notify
option.\u\s-2\(dg\s0\d
.FS
\(dg Current notable exceptions are
.I tabulate ,
.I expand ,
and the shift commands
`<'
and
`>'.
.FE
This feedback helps to detect undesirably large changes so that they may
be quickly and easily reversed with an
.I undo .
Thus if a
.I delete
command eliminates 100 lines you will be informed by a message
of the form ``100 lines deleted.''
Similarly, after commands with more global effect such as
.I global
or
.I visual ,
you will be informed if the net change in the number of lines
in the buffer during this command exceeds this threshold.
.SH
Command variants
.PP
A number of commands have two distinct variants.
The variant form of the command is invoked by placing an
`!' character after the command name.
Some of the default variants may be controlled by options;
in this case, the `!' serves to toggle the default.
Useful variants are `quit !'
which suppresses warnings about the buffer not having been written out,
and
`write !'
which allows overwriting of an existing file which is not the edited file.
.SH
Command flags
.PP
The characters `#' and `:', and the letters `p' and `l'
may be placed after many commands in any combination.
In this case, the command abbreviated by these characters
is executed after the command completes.
Any number of `+' or `\-' characters may also be given with the
option flags.
If they appear, the specified offset is applied to the current line
value before the printing command is executed.
The option
.I autoprint
makes most trailing `p' characters supplied by
.I ed
users superfluous;
as
.I autoprint
is suppressed during
.I global
commands, these flags are still often necessary.
.SH
Multiple commands on a line
.PP
More than one command may be placed on a line by separating each pair
of commands by a `|' character.
However the
.I global
commands,
and the shell escape `!'
must be the last command on a line, as they are not terminated by a `|'.
Thus the command form `write | next',
which can be abbreviated `w\||\|n',
will
.I write
the current file and then edit the
.I next
file in the argument list.
.br
.ne 20