1BSD/exrefm/exrefm7.n

.if !\n(xx .so tmac.e
.LC
.nf
( \fB.\fR , \fB.\fR ) \fBnumber\fR \fIcount\fR \fIflags\fR
.fi
.HP
The
.I number
command prints each specified line preceded by its buffer line
number.
The current line is left at the last line printed.
.LC
.nf
( \fB.\fR ) \fBopen\fR \fIflags\fR
.br
( \fB.\fR ) \fBopen\fR /\fIpat\|\fR/ \fIflags\fR
.HP
The
.I open
command enters intraline editing mode at each addressed line.
If
.I pat
is given,
then the cursor will be placed initially at the beginning of the
string matched by the pattern.\u\s-2\(dg\s0\d
.FS
\(dg The
.I pat
may be delimited only by `/' characters;
the forms `\e/' and `\e&/' are also not allowed here.
.FE
Further lines containing
.I pat
may be opened using the
.I next
`n' operation without leaving open.
The current line is left at the last line opened.
See the 
.I open
and
.I visual
mode description below for more details.
.LC
.nf
\fBpreserve\fR
.fi
.HP
The current editor buffer is saved as though the editor had just crashed.
This command is for use only in emergencies when a
.I write
command has resulted in an error and you don't know how to save your work.
After a
.I preserve
you should seek help immediately.
.LC
.nf
( \fB.\fR , \fB.\fR )\|\fBprint\fR \fIcount\fR \fIflags\fR
.fi
.HP
The
.I print
command prints the specified lines
with non-printing characters normally escaped as `?'.
The current line is left at the last line printed.
.LC
.nf
( \fB.\fR )\|\fBput\fR
.fi
.HP
The lines removed from the editing buffer by the last command which had the
ability to change the buffer are restored after the addressed line.
.I Put
can be used, e.g., after a
.I change
command to retrieve the lines changed away when you decide that you want
both these and the lines you replaced them with.
A
.I delete
command and a
.I put
command effect a
.I move .
Note that
.I put
is very similar to its
.I open
and
.I visual
mode counterpart.
.LC
.nf
\fBquit\fR \fI!\fR
.fi
.HP
The
.I quit
command causes 
.EX
to exit.
No automatic write of the editor buffer to a file is performed.
However,
.EX
issues a warning message if the file has changed
since the last write command was issued and it
offers a second chance to 
.I write .
.Ex
will also complain if there are more files in the argument
list.
The variant form suppresses these complaints.
.LC
.nf
( \fB.\fR ) \fBread\fR \fIfilename\fR
.fi
.HP
The
.I read
command places a copy of the text of the given file in the
editing buffer after the specified line.
If no 
.I filename
is given the current file name is used.
The current file name is not changed unless there is none in which
case
.I filename
becomes the current name.
The sensibility restrictions for the 
.I edit
command apply here also.
If the file buffer is empty and there is no current name then
.I ex
treats this as an
.I edit
command.
.IP
Address `0' is legal for this command and causes the file to be read at
the beginning of the buffer.
Statistics are given as for the 
.I edit
command when the 
.I read
successfully terminates.
After a
.I read
the current line is the last line read.
.LC
.nf
\fBrecover \fIfile\fR
.fi
.HP
The command
.I recover
may be used to retrieve the contents of the editor buffer after a system
crash,
editor crash,
or a
.I preserve
command.
A
.I recover
also occurs implicitly when the
.B \-r
option is specified on the command line.
A file name should be given to
.I recover
unless the file of the current name is to be recovered.
Thus a name is always required on the command line.
A
.I recover
results in the removal of the saved buffer.
The recovered buffer contents should be checked for sensibility
and then saved.
It is not possible to recover from errors occurring during a
.I recover .
.LC
.nf
\fBreset\fR
.fi
.HP
The
.I reset
command restores the default settings of all numeric and
Boolean valued options.
.LC
.nf
\fBset\fR \fIparameter\fR
.fi
.HP
The
.I set
command may be used to interrogate and to give new values to options.
With no arguments it prints those options whose values have been
changed from their defaults;
with parameter
.I all
it prints all of the option values
.IP
By giving an option name followed by a `?'
the current value of a single option may be interrogated.
The `?' is unnecessary unless the option is Boolean valued.
Boolean options are given values either by the form
`set option' to set them on or
`set nooption' to set them off;
string and numeric options are assigned via the form
`set option=value'.
More than one parameter may be given to 
.I set \|;
they are interpreted left-to-right.
.IP
It is also possible to interrogate the current values of the
current and alternate file names, and the previous
.SM UNIX
shell escape command by supplying the parameter `%', `\(ga', or `!'
respectively.
.LC
.nf
\fBshell\fR
.fi
.HP
A new
.I shell
is created.
This shell is
.I interactive ,
like a login shell.
When it terminates, editing resumes.
.LC
.nf
\fBsource\fR \fIfile\fR
.fi
.HP
The
.I source
command causes
.I ex
to read commands from the specified file.
.I Source
commands may be nested.
.LC
.nf
( \fB.\fR , \fB.\fR ) \fBsubstitute\fR /\fIpat\fR\|/\fIrepl\fR\|/ \fIoptions\fR \fIcount\fR \fIflags\fR
.fi
.HP
On each specified line, the first instance of pattern
.I pat
is replaced by replacement pattern
.I repl .
If the
.I global
indicator option character `g'
appears, then all instances are substituted;
if the
.I confirm
indication character `c' appears,
then before each substitution the line to be substituted
is typed with the string to be substituted marked
with `\(ua' characters.
By typing an `y' one can cause the substitution to be performed,
otherwise no change takes place.
After a substitute the current line is the last line substituted.
.IP
See the regular expression description for an explanation of metasequences
available in 
.I repl .
In addition to these sequences, lines may be split by substituting
new-line characters into them.
The newline in
.I repl
must be escaped by preceding it with a `\e'.
(If the 
.I substitute
is within a
.I global ,
then two escaping `\e' characters will be needed.)
.LC
.nf
\fBsync\fR
.fi
.HP
The
.I sync
command causes the contents of the editor temporary file to be
synchronized to reflect the current state of editing.
.I Sync
commands are done automatically whenever there is a difference of
15 lines or more between the in-core buffer and the temporary.
They are as useful as
.I write
commands,
and much faster,
for those who are worried about losing work due to an editor or system crash.
.LC
.nf
( \fB.\fR , \fB.\fR ) \fBtabulate\fR \fI!\fR \fIcount\fR \fIflags\fR
.fi
.HP
The
.I tabulate
command causes leading white space to be converted to 
tabs on the specified lines.
The variant causes this tabulation to occur throughout each line.
The current line is left at the last line where a change occurred.
.LC
.nf
( \fB.\fR , \fB.\fR ) \fBtranscribe\fR \fIaddr\fR
.fi
.HP
The
.I transcribe
command is a synonym for 
.I copy .
.LC
.nf
\fBundo \fI!\fI
.fi
.HP
The
.I undo
command reverses the changes made in the buffer by the last
buffer editing command.
Note that
.I global
commands are considered a single command for the purpose of 
.I undo
(as are
.I open
and
.I visual.)
Also, the commands
.I write
and
.I edit
which interact with the
.UX
file system cannot be undone.
.I Undo
is its own inverse.
After an
.I undo
the current line is the first line restored
or the line before the first line deleted if no lines were restored.
For commands with more global effect,
such as
.I global
and
.I visual
the current line regains it pre-command value after an
.I undo.
.I Undo
always marks the previous value of the current line `\fB.\fR'
as `\'\''.
.LC
.nf
( 1 , $ ) \fBv\fR /\fIpat\fR\|/ \fIcmds\fR
.fi
.HP
The
.I v
command is a synonym for the
.I global
command variant `global!'.
.LC
.nf
\fBversion\fR
.fi
.HP
The
.I version
command prints the current version number of the editor
as well as the date the binary was created.
.LC
.nf
( \fB.\fR ) \fBvisual\fR \fItype\fR \fIflags\fR
.fi
.HP
The
.I visual
command enters \fIvisual\fR mode at the specified line.
.I Type
is optional and may be `+', `\-' , `\(ua' (`^') or `\fB.\fR'
as in the
.I z
command to specify the placement of the specified line on the screen.
By default, if
.I type
is omitted, the specified line is placed as the first on the screen.
After a 
.I visual ,
the current line is the last line the cursor was on when it ended.
See the section describing 
.I visual
and
.I open
for more details.
.LC
.nf
( 1 , $ ) \fBwrite\fR \fI!\fR \fIfile\fR
.br
( 1 , $ ) \fBwrite\fR \fI!\fR >> \fIfile\fR
.fi
.HP
The
.I write
command places data from the file buffer back into the file system.
The first form of the command will write to a file only if it is
the current file and is
.I edited ,
if the file does not exist,
or if the file is actually a teletype,
.B /dev/tty
or
.B /dev/null .
If the file does not exist it is created.
The current file name is changed only if there is no current file
name.
The current line is unchanged by this command, and feedback is given
as to the number of lines and characters written as for the
.I edit
command.
The second form is used to write the buffer contents at the end of
an existing file.
For both forms,
the variant suppresses the file existence and type checks.
.IP
If an error occurs while writing the current and
.I edited
file,
.I ex
considers that there has been ``No write since last change''
even if the buffer had not previously been modified.
.LC
.nf
( \fB.\fR , \fB.\fR ) \fBxpand\fR \fIcount\fR \fIflags\fR
.fi
.HP
The
.I xpand
command is a synonym for
.I expand .
.LC
.nf
( \fB.\fR , \fB.\fR )\|\fByank\fR \fIcount\fR
.fi
.HP
The
.I yank
command causes the contents of the addressed lines to define the text
to be placed in the buffer by a succeeding
.I put
command.
The addressed lines are not affected.
A
.I yank
and a
.I put
can be used instead of a
.I copy
command.
.LC
.nf
( \fB.\fR ) \fBz\fR \fItype\fR \fIcount\fR
.fi
.HP
The
.I z
command gives access to windows of text.
The default number of logical lines in a window
is given by the numeric
.I window
option
or may be given explicitly by the
.I count
after the command.
The various types and their meanings are:
.TS
center;
c l.
\fB\&.\fR	window around the current line
\-	window ending at the current line
+	window starting after the current line
omitted	window starting at the current line
\(ua or ^	window before this window
.TE
In addition, the form
\fIz\fR=
displays a window of text with the current line in the center
delimited by lines of `\-' characters.
For all commands forms except
\fIz\fR=
the current line is left at the last line printed;
for
.I z=
`\fB.\fR' addresses the bracketed line.
.IP
The characters `+', `^' and `\-' may be repeated for
cumulative effect.
On a \s-2CRT\s0 the screen is cleared before display begins unless a
count which is less than the screen size is given.
.LC
.nf
\fB!\fIcommand\fR\fR
.fi
.HP
The remainder of the line after the `!' character is sent to a shell
to be executed.
The current line is unchanged by this command.
Within the text of
.I command
the characters 
`%' and `\`' are expanded as in filenames and the character
`!' is replaced with the text of the previous command.
Thus, in particular,
`!!' repeats the last such shell escape.
If any such expansion is performed, the expanded line will be echoed.
.IP
If there has been ``No write'' of the buffer contents since the last
change to the editing buffer, then a diagnostic will be produced
before the command is executed as a warning.
A single `!' is printed when the command completes.
.LC
.nf
( $ ) \fB=\fR
.fi
.HP
The `=' command prints the line number of the
addressed line.
The current line is unchanged.
.LC
.nf
( \fB.\fR , \fB.\fR ) \fB>\fR \fIcount\fR \fIflags\fR
.br
( \fB.\fR , \fB.\fR ) \fB<\fR \fIcount\fR \fIflags\fR
.fi
.HP
The `>' right shift and `<' left shift
commands perform intelligent shifting on the specified lines.
The quantity of shift is determined
by the
.I shiftwidth
option and the repetition of the specification character.
Thus `>>' causes the current line to be right shifted
two tab stops.
Only white space is shifted; no non-white space characters are
discarded in a left-shift.\u\s-2\(dg\s0\d
.FS
\(dg White space characters are blank and tab.
.FE
The current line becomes the last line which changed due to the
shifting.
.LC
.nf
\s-2EOF\s0
.fi
.HP
If
.EX
receives an end-of-file (control-d)
from a terminal input,
it interprets this as being a request for a scroll through the file
and sends the next
.I scroll
logical lines of text,
normally a half
.I window .
.LC
.nf
( \fB.\fR+1 ) \s-2NL\s0
.br
( \fB.\fR+1 ) |
.fi
.HP
An address alone causes the addressed line to be printed.
A blank line alone is thus useful for stepping through text.
.LC
.nf
( \fB.\fR , \fB.\fR ) \fB:\fR \fIcount\fR \fIflags\fR
.fi
.HP
The
.I colon
command is used to override the options
.I number
and
.I list
so as to print a line without these features while
the options remain set.
.LC
.nf
( \fB.\fR , \fB.\fR ) \fB&\fR \fIoptions\fR \fIcount\fR \fIflags\fR
.fi
.HP
The
`&'
command repeats the previous
.I substitute
command.
.LC
.nf
( \fB.\fR , \fB.\fR ) \fB\s+2~\s0\fR \fIoptions\fR \fIcount\fR \fIflags\fR
.fi
.HP
The
`\s+2~\s0'
command replaces the previous regular expression with the previous
replacement pattern from a substitution.
.bp