EEEExxxx RRRReeeeffffeeeerrrreeeennnncccceeee MMMMaaaannnnuuuuaaaallll
                       VVVVeeeerrrrssssiiiioooonnnn 3333....7777


                       William Joy

                       Mark Horton

                Computer Science Division
Department of Electrical Engineering and Computer Science
            University of California, Berkeley
                   Berkeley, Ca.  94720


                         _A_B_S_T_R_A_C_T

         _E_x a line oriented text  editor,  which  sup-
    ports  both  command and display oriented editing.
    This  reference  manual  describes   the   command
    oriented  part of _e_x; the display editing features
    of _e_x are described in _A_n _I_n_t_r_o_d_u_c_t_i_o_n _t_o  _D_i_s_p_l_a_y
    _E_d_i_t_i_n_g _w_i_t_h _V_i.  Other documents about the editor
    include the introduction  _E_d_i_t:  _A  _t_u_t_o_r_i_a_l,  the
    _E_x/_e_d_i_t  _C_o_m_m_a_n_d _S_u_m_m_a_r_y, and a _V_i _Q_u_i_c_k _R_e_f_e_r_e_n_c_e
    card.



_1.  _S_t_a_r_t_i_n_g _e_x

    Each instance of the editor has a set of options, which
can  be  set  to tailor it to your liking.  The command _e_d_i_t
invokes a version of _e_x designed for more casual  or  begin-
ning users by changing the default settings of some of these
options.  To  simplify  the  description  which  follows  we
assume the default settings of the options.

    When invoked, _e_x determines the terminal type from  the
TERM  variable  in  the  environment.  It there is a TERMCAP
variable in the environment, and the type  of  the  terminal
described   there  matches  the  TERM  variable,  then  that
description is used.  Also if the TERMCAP variable  contains
a  pathname  (beginning  with a ////) then the editor will seek
the description of the terminal in that  file  (rather  than
the default /etc/termcap).  If there is a variable EXINIT in
the environment, then the editor will execute  the  commands
_________________________
The financial support of an IBM Graduate Fellowship and
the  National  Science  Foundation  under grants MCS74-
07644-A03 and MCS78-07291 is gratefully acknowledged.




                    September 1, 19101





USD:16-2                                 Ex Reference Manual


in that variable, otherwise if there is a file ._e_x_r_c in your
HOME  directory _e_x reads commands from that file, simulating
a _s_o_u_r_c_e command.  Option setting commands placed in  EXINIT
or ._e_x_r_c will be executed before each editor session.

    A command to enter _e_x has the following prototype:|-

       eeeexxxx [ ---- ] [ ----vvvv ] [ ----tttt _t_a_g ] [ ----rrrr ] [ ----llll ] [ ----wwww_n ] [ ----xxxx ] [ ----RRRR ] [ ++++_c_o_m_m_a_n_d ] name ...

The most common case edits a single file  with  no  options,
i.e.:

       eeeexxxx name

The  -   command   line   option   option   suppresses   all
interactive-user feedback and is useful in processing editor
scripts in command files.  The -_v option  is  equivalent  to
using  _v_i rather than _e_x.  The -_t option is equivalent to an
initial _t_a_g command, editing the file containing the _t_a_g and
positioning  the editor at its definition.  The -_r option is
used in recovering after an editor or system crash, retriev-
ing  the last saved version of the named file or, if no file
is specified, typing a list of saved files.  The  -_l  option
sets  up  for  editing  LISP, setting the _s_h_o_w_m_a_t_c_h and _l_i_s_p
options.  The -_w option sets the default window size  to  _n,
and  is useful on dialups to start in small windows.  The -_x
option causes _e_x to prompt for  a  _k_e_y,  which  is  used  to
encrypt  and  decrypt the contents of the file, which should
already be encrypted using the same key, see _c_r_y_p_t(1).   The
-_R option sets the _r_e_a_d_o_n_l_y option at the start.  _N_a_m_e argu-
ments indicate files to be edited.  An argument of the  form
++++_c_o_m_m_a_n_d indicates that the editor should begin by executing
the specified command.   If  _c_o_m_m_a_n_d  is  omitted,  then  it
defaults  to  ``$'', positioning the editor at the last line
of the first file initially.  Other useful commands here are
scanning patterns of the form ``/pat'' or line numbers, e.g.
``+100'' starting at line 100.

_2.  _F_i_l_e _m_a_n_i_p_u_l_a_t_i_o_n

_2._1.  _C_u_r_r_e_n_t _f_i_l_e

    _E_x is normally editing the contents of a  single  file,
whose  name  is  recorded in the _c_u_r_r_e_n_t file name.  _E_x per-
forms all editing actions in a buffer (actually a  temporary
file)  into  which  the  text of the file is initially read.
Changes made to the buffer have no effect on the file  being
edited  unless and until the buffer contents are written out
to the file with a _w_r_i_t_e command.  After the buffer contents
are  written,  the previous contents of the written file are
no longer accessible.  When  a  file  is  edited,  its  name
_________________________
|- Brackets `[' `]' surround optional parameters here.




                    September 1, 19101





Ex Reference Manual                                 USD:16-3


becomes the current file name, and  its  contents  are  read
into the buffer.

    The current file is  almost  always  considered  to  be
_e_d_i_t_e_d.  This means that the contents of the buffer are log-
ically connected with the current file name, so that writing
the  current  buffer  contents  onto  that  file, even if it
exists, is a reasonable action.  If the current file is  not
_e_d_i_t_e_d  then  _e_x will not normally write on it if it already
exists.*

_2._2.  _A_l_t_e_r_n_a_t_e _f_i_l_e

    Each time a new value is  given  to  the  current  file
name,  the previous current file name is saved as the _a_l_t_e_r_-
_n_a_t_e file name.  Similarly if a file is mentioned  but  does
not  become  the  current file, it is saved as the alternate
file name.

_2._3.  _F_i_l_e_n_a_m_e _e_x_p_a_n_s_i_o_n

    Filenames within the editor may be specified using  the
normal  shell expansion conventions.  In addition, the char-
acter `%' in filenames is replaced by the _c_u_r_r_e_n_t file  name
and the character `#' by the _a_l_t_e_r_n_a_t_e file name.|-

_2._4.  _M_u_l_t_i_p_l_e _f_i_l_e_s _a_n_d _n_a_m_e_d _b_u_f_f_e_r_s

    If more than one file is given  on  the  command  line,
then  the  first  file  is  edited  as described above.  The
remaining arguments are placed with the first  file  in  the
_a_r_g_u_m_e_n_t  _l_i_s_t.   The current argument list may be displayed
with the _a_r_g_s command.  The next file in the  argument  list
may  be edited with the _n_e_x_t command.  The argument list may
also be respecified by specifying a list  of  names  to  the
_n_e_x_t  command.  These names are expanded, the resulting list
of names becomes the new argument list,  and  _e_x  edits  the
first file on the list.

    For saving blocks of text while editing, and especially
when  editing  more  than  one file, _e_x has a group of named
buffers.  These are similar to  the  normal  buffer,  except
that  only  a  limited number of operations are available on
them.  The buffers have names _a through _z.|=
_________________________
* The _f_i_l_e command will say  ``[Not  edited]''  if  the
current file is not considered edited.
|- This makes it easy to deal alternately with two files
and eliminates the need for retyping the name  supplied
on  an  _e_d_i_t command after a _N_o _w_r_i_t_e _s_i_n_c_e _l_a_s_t _c_h_a_n_g_e
diagnostic is received.
|= It is also possible to refer  to  _A  through  _Z;  the
upper  case  buffers  are  the  same  as  the lower but
commands append to named buffers rather than  replacing



                    September 1, 19101





USD:16-4                                 Ex Reference Manual


_2._5.  _R_e_a_d _o_n_l_y

    It is possible to use _e_x in _r_e_a_d _o_n_l_y mode to  look  at
files  that  you  have no intention of modifying.  This mode
protects you from accidently  overwriting  the  file.   Read
only  mode is on when the _r_e_a_d_o_n_l_y option is set.  It can be
turned on with the -_R command line option, by the _v_i_e_w  com-
mand line invocation, or by setting the _r_e_a_d_o_n_l_y option.  It
can be cleared by setting _n_o_r_e_a_d_o_n_l_y.   It  is  possible  to
write,  even while in read only mode, by indicating that you
really know what you are doing.  You can  write  to  a  dif-
ferent  file,  or can use the ! form of write, even while in
read only mode.

_3.  _E_x_c_e_p_t_i_o_n_a_l _C_o_n_d_i_t_i_o_n_s

_3._1.  _E_r_r_o_r_s _a_n_d _i_n_t_e_r_r_u_p_t_s

    When errors occur _e_x (optionally)  rings  the  terminal
bell  and,  in any case, prints an error diagnostic.  If the
primary input is from a file, editor  processing  will  ter-
minate.   If  an  interrupt  signal  is  received, _e_x prints
``Interrupt'' and returns to its command level.  If the pri-
mary input is a file, then _e_x will exit when this occurs.

_3._2.  _R_e_c_o_v_e_r_i_n_g _f_r_o_m _h_a_n_g_u_p_s _a_n_d _c_r_a_s_h_e_s

    If a hangup signal is received and the buffer has  been
modified  since  it  was  last written out, or if the system
crashes, either the editor (in the first case) or the system
(after  it  reboots  in the second) will attempt to preserve
the buffer.  The next time you log in you should be able  to
recover  the work you were doing, losing at most a few lines
of changes from the last point before the hangup  or  editor
crash.  To recover a file you can use the -_r option.  If you
were editing the file _r_e_s_u_m_e, then you should change to  the
directory where you were when the crash occurred, giving the
command

       eeeexxxx ----rrrr _r_e_s_u_m_e

After checking that the retrieved file is indeed ok, you can
_w_r_i_t_e it over the previous contents of that file.

    You will normally get mail from the system telling  you
when a file has been saved after a crash.  The command

       eeeexxxx -rrrr

will print a list of the files which  have  been  saved  for
you.   (In the case of a hangup, the file will not appear in
_________________________
if upper case names are used.




                    September 1, 19101





Ex Reference Manual                                 USD:16-5


the list, although it can be recovered.)

_4.  _E_d_i_t_i_n_g _m_o_d_e_s

    _E_x has five distinct modes.  The primary mode  is  _c_o_m_-
_m_a_n_d  mode.  Commands are entered in command mode when a `:'
prompt is present, and are executed  each  time  a  complete
line is sent.  In _t_e_x_t _i_n_p_u_t mode _e_x gathers input lines and
places them in the file.  The  _a_p_p_e_n_d,  _i_n_s_e_r_t,  and  _c_h_a_n_g_e
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, and _c_o_m_m_a_n_d mode resumes.

    The last three modes are _o_p_e_n and _v_i_s_u_a_l modes, entered
by  the  commands  of  the  same  name, and, within open and
visual modes _t_e_x_t _i_n_s_e_r_t_i_o_n mode.   _O_p_e_n  and  _v_i_s_u_a_l  modes
allow  local  editing operations to be performed on the text
in the file.  The _o_p_e_n command displays one line at  a  time
on  any  terminal  while  _v_i_s_u_a_l works on CRT terminals with
random positioning cursors, using the screen as  a  (single)
window  for file editing changes.  These modes are described
(only) in _A_n _I_n_t_r_o_d_u_c_t_i_o_n _t_o _D_i_s_p_l_a_y _E_d_i_t_i_n_g _w_i_t_h _V_i.

_5.  _C_o_m_m_a_n_d _s_t_r_u_c_t_u_r_e

    Most command names are English words, and initial  pre-
fixes  of the words are acceptable abbreviations.  The ambi-
guity of abbreviations is resolved in favor of the more com-
monly used commands.*

_5._1.  _C_o_m_m_a_n_d _p_a_r_a_m_e_t_e_r_s

    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 _c_o_u_n_t 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.

    Some commands take  other  information  or  parameters,
this information always being given after the command name.|=

_________________________
*  As  an  example,  the  command  _s_u_b_s_t_i_t_u_t_e  can   be
abbreviated    `s'   while   the   shortest   available
abbreviation for the _s_e_t command is `se'.
|- Counts are rounded down if necessary.
|=  Examples would be option names in a _s_e_t command i.e.
``set number'', a file  name  in  an  _e_d_i_t  command,  a
regular expression in a _s_u_b_s_t_i_t_u_t_e command, or a target
address for a _c_o_p_y command, i.e. ``1,5 copy 25''.




                    September 1, 19101





USD:16-6                                 Ex Reference Manual


_5._2.  _C_o_m_m_a_n_d _v_a_r_i_a_n_t_s

    A number of commands have two distinct  variants.   The
variant  form  of  the  command is invoked by placing an `!'
immediately after the command name.   Some  of  the  default
variants may be controlled by options; in this case, the `!'
serves to toggle the default.

_5._3.  _F_l_a_g_s _a_f_t_e_r _c_o_m_m_a_n_d_s

    The characters `#', `p' and `l'  may  be  placed  after
many commands.**  In this case, the command  abbreviated  by
these  characters  is  executed after the command completes.
Since _e_x normally prints the new  current  line  after  each
change,  `p'  is rarely necessary.  Any number of `+' or `-'
characters may also be given  with  these  flags.   If  they
appear,  the specified offset is applied to the current line
value before the printing command is executed.

_5._4.  _C_o_m_m_e_n_t_s

    It is  possible  to  give  editor  commands  which  are
ignored.   This is useful when making complex editor scripts
for which comments are desired.  The  comment  character  is
the  double  quote: ".  Any command line beginning with " is
ignored.  Comments beginning with " may also  be  placed  at
the  ends  of  commands, except in cases where they could be
confused as part of text (shell escapes and  the  substitute
and map commands).

_5._5.  _M_u_l_t_i_p_l_e _c_o_m_m_a_n_d_s _p_e_r _l_i_n_e

    More than one command  may  be  placed  on  a  line  by
separating  each  pair of commands by a `|' character.  How-
ever the _g_l_o_b_a_l commands, comments, and the shell escape `!'
must  be  the  last  command on a line, as they are not ter-
minated by a `|'.

_5._6.  _R_e_p_o_r_t_i_n_g _l_a_r_g_e _c_h_a_n_g_e_s

    Most commands which change the contents of  the  editor
buffer  give  feedback  if the scope of the change exceeds a
threshold given by the _r_e_p_o_r_t option.  This  feedback  helps
to  detect  undesirably  large  changes  so that they may be
quickly and easily reversed with an  _u_n_d_o.   After  commands
with  more  global effect such as _g_l_o_b_a_l or _v_i_s_u_a_l, you will
be informed if the net change in the number of lines in  the
buffer during this command exceeds this threshold.


_________________________
** A `p' or `l' must be preceded  by  a  blank  or  tab
except in the single special case `dp'.




                    September 1, 19101





Ex Reference Manual                                 USD:16-7


_6.  _C_o_m_m_a_n_d _a_d_d_r_e_s_s_i_n_g

_6._1.  _A_d_d_r_e_s_s_i_n_g _p_r_i_m_i_t_i_v_e_s

...                   The current line.  Most  commands  leave
                   the  current line as the last line which
                   they affect.  The  default  address  for
                   most  commands is the current line, thus
                   `....' is rarely used alone as an address.

_n                   The _nth line  in  the  editor's  buffer,
                   lines  being  numbered sequentially from
                   1.

$$$$                   The last line in the buffer.

%%%%                   An abbreviation for ``1,$'', the  entire
                   buffer.

+_n -_n               An offset relative to the current buffer
                   line.|-

////_p_a_t//// ????_p_a_t????         Scan forward and  backward  respectively
                   for  a  line  containing  _p_a_t, a regular
                   expression  (as  defined  below).    The
                   scans  normally  wrap  around the end of
                   the buffer.  If all that is  desired  is
                   to  print  the next line containing _p_a_t,
                   then the trailing //// or ???? may be omitted.
                   If  _p_a_t  is omitted or explicitly empty,
                   then the last regular expression  speci-
                   fied is located.|=

'''''''' ''''_x               Before each non-relative motion  of  the
                   current  line  `....', the previous current
                   line is marked with a tag,  subsequently
                   referred to as `'''.  This makes it easy
                   to refer or return to this previous con-
                   text.   Marks may also be established by
                   the _m_a_r_k  command,  using  single  lower
                   case  letters  _x  and  the  marked lines
                   referred to as `'_x'.

_6._2.  _C_o_m_b_i_n_i_n_g _a_d_d_r_e_s_s_i_n_g _p_r_i_m_i_t_i_v_e_s

    Addresses to commands consist of a series of addressing
primitives, separated by `,' or `;'.  Such address lists are
_________________________
|- The forms `.+3' `+3' and `+++' are all equivalent; if
the current line is line 100 they all address line 103.
|=  The  forms  \\\\////  and  \\\\????  scan using the last regular
expression used in a scan; after a substitute //////// and ????????
would scan using the substitute's regular expression.




                    September 1, 19101





USD:16-8                                 Ex Reference Manual


evaluated left-to-right.  When addresses  are  separated  by
`;'  the current line `....'  is set to the value of the previ-
ous addressing expression before the next address is  inter-
preted.   If  more  addresses  are  given  than  the command
requires, then all but the last one or two are ignored.   If
the  command  takes  two addresses, the first addressed line
must precede the second in the buffer.|-

_7.  _C_o_m_m_a_n_d _d_e_s_c_r_i_p_t_i_o_n_s

    The following form is a prototype for all _e_x commands:

       _a_d_d_r_e_s_s ccccoooommmmmmmmaaaannnndddd ! _p_a_r_a_m_e_t_e_r_s _c_o_u_n_t _f_l_a_g_s

All parts are optional; the degenerate  case  is  the  empty
command  which prints the next line in the file.  For sanity
with use from within _v_i_s_u_a_l mode, _e_x ignores a ``:'' preced-
ing any command.

    In the  following  command  descriptions,  the  default
addresses  are shown in parentheses, which are _n_o_t, however,
part of the command.
9
aaaabbbbbbbbrrrreeeevvvviiiiaaaatttteeee _w_o_r_d _r_h_s                     abbr: aaaabbbb

    Add the named abbreviation to the current  list.   When
    in input mode in visual, if _w_o_r_d is typed as a complete
    word, it will be changed to _r_h_s.
9
( .... ) aaaappppppppeeeennnndddd                            abbr: aaaa
_t_e_x_t
...

    Reads the input text and places it after the  specified
    line.   After the command, `....'  addresses the last line
    input or the specified line if no lines were input.  If
    address  `0'  is given, text is placed at the beginning
    of the buffer.
9
aaaa!!!!
_t_e_x_t
...

    The variant flag to _a_p_p_e_n_d toggles the setting for  the
    _a_u_t_o_i_n_d_e_n_t option during the input of _t_e_x_t.
9_________________________
|- Null address specifications are permitted in  a  list
of  addresses,  the default in this case is the current
line `.'; thus `,100' is equivalent to `....,100'.  It  is
an  error  to  give a prefix address to a command which
expects none.




                    September 1, 19101





Ex Reference Manual                                 USD:16-9


aaaarrrrggggssss

    The members of the argument list are printed, with  the
    current argument delimited by `[' and `]'.
9
( .... , .... ) cccchhhhaaaannnnggggeeee _c_o_u_n_t                  abbr: cccc
_t_e_x_t
...

    Replaces the specified lines with the input _t_e_x_t.   The
    current  line  becomes the last line input; if no lines
    were input it is left as for a _d_e_l_e_t_e.
9
cccc!!!!
_t_e_x_t
...

    The variant toggles _a_u_t_o_i_n_d_e_n_t during the _c_h_a_n_g_e.
9
( .... , .... )ccccooooppppyyyy _a_d_d_r _f_l_a_g_s                abbr: ccccoooo

    A _c_o_p_y of the specified lines  is  placed  after  _a_d_d_r,
    which  may be `0'.  The current line `....'  addresses the
    last line of the copy.  The command _t is a synonym  for
    _c_o_p_y.
9
( .... , .... )ddddeeeelllleeeetttteeee _b_u_f_f_e_r _c_o_u_n_t _f_l_a_g_s      abbr: dddd

    Removes the specified lines from the buffer.  The  line
    after  the  last line deleted becomes the current line;
    if the lines deleted were originally at  the  end,  the
    new  last  line  becomes  the current line.  If a named
    _b_u_f_f_e_r is specified by giving a letter, then the speci-
    fied  lines are saved in that buffer, or appended to it
    if an upper case letter is used.
9
eeeeddddiiiitttt _f_i_l_e                               abbr: eeee
eeeexxxx _f_i_l_e

    Used to begin an editing session on a  new  file.   The
    editor first checks to see if the buffer has been modi-
    fied since the last _w_r_i_t_e command was  issued.   If  it
    has  been,  a  warning  is  issued  and  the command is
    aborted.  The command otherwise deletes the entire con-
    tents  of  the  editor buffer, makes the named file the
    current file and prints the new filename.  After insur-
    ing that this file is sensible|- the  editor  reads  the
_________________________
|- I.e., that  it  is  not  a  binary  file  such  as  a
directory, a block or character special file other than
/_d_e_v/_t_t_y, a terminal, or a binary  or  executable  file
(as indicated by the first word).


9                     September 1, 19101





USD:16-10                                Ex Reference Manual


    file into its buffer.

    If the read of the file completes  without  error,  the
    number of lines and characters read is typed.  If there
    were any non-ASCII characters  in  the  file  they  are
    stripped  of  their  non-ASCII  high bits, and any null
    characters in the file are discarded.  If none of these
    errors occurred, the file is considered _e_d_i_t_e_d.  If the
    last line of the input file  is  missing  the  trailing
    newline  character, it will be supplied and a complaint
    will be issued.  This command leaves the  current  line
    `....' at the last line read.|=
9
eeee!!!! _f_i_l_e

    The variant form suppresses the complaint about modifi-
    cations  having been made and not written from the edi-
    tor buffer, thus discarding all changes which have been
    made before editing the new file.
9
eeee ++++_n _f_i_l_e

    Causes the editor to begin at line _n rather than at the
    last  line;  _n may also be an editor command containing
    no spaces, e.g.: ``+/pat''.
9
ffffiiiilllleeee                                    abbr: ffff

    Prints the current  file  name,  whether  it  has  been
    `[Modified]'  since  the last _w_r_i_t_e command, whether it
    is _r_e_a_d _o_n_l_y, the current line, the number of lines  in
    the  buffer,  and the percentage of the way through the
    buffer of the current line.*
9
ffffiiiilllleeee _f_i_l_e

    The current file name is changed to _f_i_l_e which is  con-
    sidered `[Not edited]'.
9
( 1 , $ ) gggglllloooobbbbaaaallll /_p_a_t/ _c_m_d_s             abbr: gggg

    First marks  each  line  among  those  specified  which
    matches  the  given regular expression.  Then the given
_________________________
|= If executed from within _o_p_e_n or _v_i_s_u_a_l,  the  current
line is initially the first line of the file.
* In the rare case  that  the  current  file  is  `[Not
edited]'  this  is noted also; in this case you have to
use the form wwww!!!! to write to the file, since the  editor
is  not  sure  that  a  wwwwrrrriiiitttteeee  will  not destroy a file
unrelated to the current contents of the buffer.
9


                    September 1, 19101





Ex Reference Manual                                USD:16-11


    command list is executed with `....' initially set to each
    marked line.

    The command list consists of the remaining commands  on
    the  current  input  line  and may continue to multiple
    lines by ending all but the last such line with a  `\'.
    If  _c_m_d_s  (and  possibly  the  trailing //// delimiter) is
    omitted, each line matching _p_a_t  is  printed.   _A_p_p_e_n_d,
    _i_n_s_e_r_t,  and  _c_h_a_n_g_e  commands and associated input are
    permitted; the `....' terminating input may be omitted  if
    it would be on the last line of the command list.  _O_p_e_n
    and _v_i_s_u_a_l commands are permitted in the  command  list
    and take input from the terminal.

    The _g_l_o_b_a_l command itself may not appear in _c_m_d_s.   The
    _u_n_d_o  command  is  also  not  permitted  there, as _u_n_d_o
    instead can be used to reverse the entire  _g_l_o_b_a_l  com-
    mand.   The  options _a_u_t_o_p_r_i_n_t and _a_u_t_o_i_n_d_e_n_t are inhi-
    bited during a _g_l_o_b_a_l, (and  possibly  the  trailing  ////
    delimiter)  and  the value of the _r_e_p_o_r_t option is tem-
    porarily infinite, in deference to  a  _r_e_p_o_r_t  for  the
    entire  global.   Finally, the context mark `''' is set
    to the value of `.' before the  global  command  begins
    and  is  not  changed  during  a global command, except
    perhaps by an _o_p_e_n or _v_i_s_u_a_l within the _g_l_o_b_a_l.
9
gggg!!!! ////_p_a_t//// _c_m_d_s                           abbr: vvvv

    The variant form of _g_l_o_b_a_l runs _c_m_d_s at each  line  not
    matching _p_a_t.
9
( .... )iiiinnnnsssseeeerrrrtttt                             abbr: iiii
_t_e_x_t
...

    Places the given text before the specified  line.   The
    current  line  is left at the last line input; if there
    were none input it is  left  at  the  line  before  the
    addressed  line.  This command differs from _a_p_p_e_n_d only
    in the placement of text.
9
iiii!!!!
_t_e_x_t
...

    The variant toggles _a_u_t_o_i_n_d_e_n_t during the _i_n_s_e_r_t.
9
( .... , ....+1 ) jjjjooooiiiinnnn _c_o_u_n_t _f_l_a_g_s            abbr: jjjj

    Places  the  text  from  a  specified  range  of  lines
    together  on one line.  White space is adjusted at each
    junction to provide at least one blank  character,  two



                    September 1, 19101





USD:16-12                                Ex Reference Manual


    if  there  was a `....' at the end of the line, or none if
    the first following character is a `)'.   If  there  is
    already  white  space  at the end of the line, then the
    white space at the start of the next line will be  dis-
    carded.
9
jjjj!!!!

    The variant causes a simpler _j_o_i_n with no  white  space
    processing; the characters in the lines are simply con-
    catenated.
9
( .... ) kkkk _x

    The _k command is a  synonym  for  _m_a_r_k.   It  does  not
    require a blank or tab before the following letter.
9
( .... , .... ) lllliiiisssstttt _c_o_u_n_t _f_l_a_g_s

    Prints the specified lines in a more  unambiguous  way:
    tabs  are  printed  as `^I' and the end of each line is
    marked with a trailing `$'.  The current line  is  left
    at the last line printed.
9
mmmmaaaapppp _l_h_s _r_h_s

    The _m_a_p command is used to define  macros  for  use  in
    _v_i_s_u_a_l  mode.  _L_h_s should be a single character, or the
    sequence ``#n'', for n a digit, referring  to  function
    key _n.  When this character or function key is typed in
    _v_i_s_u_a_l mode, it will be as though the corresponding _r_h_s
    had  been  typed.   On terminals without function keys,
    you can type ``#n''.  See section 6.9 of  the  ``Intro-
    duction to Display Editing with Vi'' for more details.
9
( .... ) mmmmaaaarrrrkkkk _x

    Gives the specified line mark _x, a  single  lower  case
    letter.   The  _x  must be preceded by a blank or a tab.
    The addressing form `'x' then addresses this line.  The
    current line is not affected by this command.
9
( .... , .... ) mmmmoooovvvveeee _a_d_d_r                     abbr: mmmm

    The _m_o_v_e command repositions the specified lines to  be
    after  _a_d_d_r.   The first of the moved lines becomes the
    current line.
9


9


                    September 1, 19101





Ex Reference Manual                                USD:16-13


nnnneeeexxxxtttt                                    abbr: nnnn

    The next file from the command line  argument  list  is
    edited.
9
nnnn!!!!

    The variant suppresses warnings about the modifications
    to  the  buffer not having been written out, discarding
    (irretrievably) any changes which may have been made.
9
nnnn _f_i_l_e_l_i_s_t
nnnn ++++_c_o_m_m_a_n_d _f_i_l_e_l_i_s_t

    The specified _f_i_l_e_l_i_s_t is expanded  and  the  resulting
    list replaces the current argument list; the first file
    in the new list is then edited.  If  _c_o_m_m_a_n_d  is  given
    (it  must contain no spaces), then it is executed after
    editing the first such file.
9
( .... , .... ) nnnnuuuummmmbbbbeeeerrrr _c_o_u_n_t _f_l_a_g_s            abbr: #### or nnnnuuuu

    Prints each specified line preceded by its buffer  line
    number.   The  current  line  is  left at the last line
    printed.
9
( .... ) ooooppppeeeennnn _f_l_a_g_s                        abbr: oooo
( .... ) ooooppppeeeennnn /_p_a_t/ _f_l_a_g_s

    Enters intraline editing _o_p_e_n mode  at  each  addressed
    line.   If _p_a_t is given, then the cursor will be placed
    initially at the beginning of the string matched by the
    pattern.  To exit this mode use Q.  See _A_n _I_n_t_r_o_d_u_c_t_i_o_n
    _t_o _D_i_s_p_l_a_y _E_d_i_t_i_n_g _w_i_t_h _V_i for more details.
9
pppprrrreeeesssseeeerrrrvvvveeee

    The current editor buffer is saved as though the system
    had  just  crashed.   This  command  is for use only in
    emergencies when a _w_r_i_t_e command  has  resulted  in  an
    error  and you don't know how to save your work.  After
    a _p_r_e_s_e_r_v_e you should seek help.
9
( .... , .... )pppprrrriiiinnnntttt _c_o_u_n_t                    abbr: pppp or PPPP

    Prints the specified lines with non-printing characters
    printed  as control characters `^_x'; delete (octal 177)
    is represented as `^?'.  The current line  is  left  at
    the last line printed.
9
9


                    September 1, 19101





USD:16-14                                Ex Reference Manual


( .... )ppppuuuutttt _b_u_f_f_e_r                         abbr: ppppuuuu

    Puts back previously _d_e_l_e_t_e_d or _y_a_n_k_e_d lines.  Normally
    used  with  _d_e_l_e_t_e to effect movement of lines, or with
    _y_a_n_k to effect duplication of lines.  If no  _b_u_f_f_e_r  is
    specified,  then  the  last  _d_e_l_e_t_e_d  or _y_a_n_k_e_d text is
    restored.*  By  using  a  named  buffer,  text  may  be
    restored that was saved there at any previous time.
9
qqqquuuuiiiitttt                                    abbr: qqqq

    Causes _e_x to terminate.  No automatic write of the edi-
    tor  buffer to a file is performed.  However, _e_x issues
    a warning message if the file  has  changed  since  the
    last _w_r_i_t_e command was issued, and does not _q_u_i_t.|- Nor-
    mally,  you  will  wish  to  save your changes, and you
    should give a _w_r_i_t_e command; if  you  wish  to  discard
    them, use the qqqq!!!! command variant.
9
qqqq!!!!

    Quits from the editor, discarding changes to the buffer
    without complaint.
9
( .... ) rrrreeeeaaaadddd _f_i_l_e                         abbr: rrrr

    Places a copy of the text of  the  given  file  in  the
    editing buffer after the specified line.  If no _f_i_l_e is
    given the current file name is used.  The current  file
    name  is not changed unless there is none in which case
    _f_i_l_e becomes the current name.   The  sensibility  res-
    trictions for the _e_d_i_t command apply here also.  If the
    file buffer is empty and there is no current name  then
    _e_x treats this as an _e_d_i_t command.

    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 _e_d_i_t command  when  the
    _r_e_a_d successfully terminates.  After a _r_e_a_d the current
    line is the last line read.|=
9


_________________________
* But no modifying commands may intervene  between  the
_d_e_l_e_t_e  or  _y_a_n_k  and  the  _p_u_t, nor may lines be moved
between files without using a named buffer.
|-  _E_x  will  also  issue a diagnostic if there are more
files in the argument list.
|= Within _o_p_e_n and _v_i_s_u_a_l the current line is set to the
first line read rather than the last.




                    September 1, 19101





Ex Reference Manual                                USD:16-15


( .... ) rrrreeeeaaaadddd  !!!!_c_o_m_m_a_n_d

    Reads the output of the command _c_o_m_m_a_n_d into the buffer
    after  the  specified line.  This is not a variant form
    of the command, rather  a  read  specifying  a  _c_o_m_m_a_n_d
    rather  than a _f_i_l_e_n_a_m_e; a blank or tab before the !!!! is
    mandatory.
9
rrrreeeeccccoooovvvveeeerrrr _f_i_l_e

    Recovers _f_i_l_e from the system save area.  Used after  a
    accidental hangup of the phone** or a system crash** or
    _p_r_e_s_e_r_v_e  command.   Except  when  you use _p_r_e_s_e_r_v_e you
    will be notified by mail when a file is saved.
9
rrrreeeewwwwiiiinnnndddd                                  abbr: rrrreeeewwww

    The argument list is rewound, and the first file in the
    list is edited.
9
rrrreeeewwww!!!!

    Rewinds the argument list discarding any  changes  made
    to the current buffer.
9
sssseeeetttt _p_a_r_a_m_e_t_e_r

    With no arguments, prints those  options  whose  values
    have  been  changed from their defaults; with parameter
    _a_l_l it prints all of the option values.

    Giving an option name followed by  a  `?'   causes  the
    current value of that option to be printed.  The `?' is
    unnecessary  unless  the  option  is  Boolean   valued.
    Boolean  options  are  given  values either by the form
    `set _o_p_t_i_o_n' to turn them on or `set no_o_p_t_i_o_n' to  turn
    them  off;  string and numeric options are assigned via
    the form `set _o_p_t_i_o_n=value'.

    More than one parameter may be given to _s_e_t;  they  are
    interpreted left-to-right.
9
sssshhhheeeellllllll                                   abbr: sssshhhh

    A new shell is created.  When  it  terminates,  editing
    resumes.
9
_________________________
** The system saves a copy of the file you were editing
only if you have made changes to the file.




                    September 1, 19101





USD:16-16                                Ex Reference Manual


ssssoooouuuurrrrcccceeee _f_i_l_e                             abbr: ssssoooo

    Reads and executes commands from  the  specified  file.
    _S_o_u_r_c_e commands may be nested.
9
( .... , .... ) ssssuuuubbbbssssttttiiiittttuuuutttteeee /_p_a_t/_r_e_p_l/ _o_p_t_i_o_n_s _c_o_u_n_t _f_l_a_g_sabbr: ssss

    On each specified line, the first instance  of  pattern
    _p_a_t  is  replaced  by replacement pattern _r_e_p_l.  If the
    _g_l_o_b_a_l indicator option character `g' appears, then all
    instances  are  substituted;  if the _c_o_n_f_i_r_m indication
    character `c' appears, then  before  each  substitution
    the  line to be substituted is typed with the string to
    be substituted marked with `|^' characters.   By  typing
    an  `y' one can cause the substitution to be performed,
    any other input causes no change to take place.   After
    a  _s_u_b_s_t_i_t_u_t_e the current line is the last line substi-
    tuted.

    Lines may be split by substituting new-line  characters
    into  them.   The  newline  in  _r_e_p_l must be escaped by
    preceding it with a `\'.  Other  metacharacters  avail-
    able in _p_a_t and _r_e_p_l are described below.
9
_s_t_o_p

    Suspends the editor, returning control to the top level
    shell.   If  _a_u_t_o_w_r_i_t_e  is  set  and  there are unsaved
    changes, a write is done first unless  the  form  _s_t_o_p!
    is  used.   This  commands is only available where sup-
    ported by the teletype driver and operating system.
9
( .... , .... ) ssssuuuubbbbssssttttiiiittttuuuutttteeee _o_p_t_i_o_n_s _c_o_u_n_t _f_l_a_g_sabbr: ssss

    If _p_a_t and _r_e_p_l are omitted, then the last substitution
    is repeated.  This is a synonym for the & command.
9
( .... , .... ) tttt _a_d_d_r _f_l_a_g_s

    The _t command is a synonym for _c_o_p_y.
9
ttttaaaa _t_a_g

    The focus of editing switches to the location  of  _t_a_g,
    switching to a different line in the current file where
    it is defined, or if necessary to another file.|=
9_________________________
|= If you have modified the current file before giving a
_t_a_g  command, you must write it out; giving another _t_a_g
command, specifying no _t_a_g will reuse the previous tag.




                    September 1, 19101





Ex Reference Manual                                USD:16-17


    The tags file is normally created by a program such  as
    _c_t_a_g_s,  and  consists  of  a number of lines with three
    fields separated by blanks or tabs.   The  first  field
    gives  the  name of the tag, the second the name of the
    file where the tag resides,  and  the  third  gives  an
    addressing form which can be used by the editor to find
    the tag; this field is usually a contextual scan  using
    `/_p_a_t/'  to  be  immune  to  minor changes in the file.
    Such scans are always performed as if _n_o_m_a_g_i_c was set.

    The tag names in the tags file must be sorted alphabet-
ically.
9
uuuunnnnaaaabbbbbbbbrrrreeeevvvviiiiaaaatttteeee _w_o_r_d                       abbr: uuuunnnnaaaa

    Delete _w_o_r_d from the list of abbreviations.
9
uuuunnnnddddoooo                                    abbr: uuuu

    Reverses the changes made in the  buffer  by  the  last
    buffer  editing command.  Note that _g_l_o_b_a_l commands are
    considered a single command for the purpose of _u_n_d_o (as
    are  _o_p_e_n  and  _v_i_s_u_a_l.)   Also, the commands _w_r_i_t_e and
    _e_d_i_t which interact with  the  file  system  cannot  be
    undone.  _U_n_d_o is its own inverse.

    _U_n_d_o always marks the previous  value  of  the  current
    line  `....'   as `'''.  After an _u_n_d_o 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 _g_l_o_b_a_l and  _v_i_s_u_a_l  the
    current  line  regains  it's pre-command value after an
    _u_n_d_o.
9
uuuunnnnmmmmaaaapppp _l_h_s

    The macro  expansion  associated  by  _m_a_p  for  _l_h_s  is
    removed.
9
( 1 , $ ) vvvv /_p_a_t/ _c_m_d_s

    A synonym for the _g_l_o_b_a_l command  variant  gggg!!!!,  running
    the  specified  _c_m_d_s  on each line which does not match
    _p_a_t.
9
vvvveeeerrrrssssiiiioooonnnn                                 abbr: vvvveeee

    Prints the current version number of the editor as well
    as the date the editor was last changed.
9




                    September 1, 19101





USD:16-18                                Ex Reference Manual


( .... ) vvvviiiissssuuuuaaaallll _t_y_p_e _c_o_u_n_t _f_l_a_g_s           abbr: vvvviiii

    Enters visual mode at  the  specified  line.   _T_y_p_e  is
    optional  and may be `-' , `|^' or `....'  as in the _z com-
    mand to specify the placement of the specified line  on
    the screen.  By default, if _t_y_p_e is omitted, the speci-
    fied line is placed as the  first  on  the  screen.   A
    _c_o_u_n_t  specifies an initial window size; the default is
    the value of the option _w_i_n_d_o_w.  See  the  document  _A_n
    _I_n_t_r_o_d_u_c_t_i_o_n  _t_o  _D_i_s_p_l_a_y  _E_d_i_t_i_n_g  _w_i_t_h  _V_i  for  more
    details.  To exit this mode, type Q.
9
vvvviiiissssuuuuaaaallll file
vvvviiiissssuuuuaaaallll +_n file

    From visual mode, this command is the same as edit.
9
( 1 , $ ) wwwwrrrriiiitttteeee _f_i_l_e                    abbr: wwww

    Writes changes made back to _f_i_l_e, printing  the  number
    of  lines  and  characters  written.   Normally _f_i_l_e is
    omitted and the text goes back where it came from.   If
    a  _f_i_l_e is specified, then text will be written to that
    file.*  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 never changed.

    If an error occurs while writing the current and _e_d_i_t_e_d
    file,  the  editor  considers  that there has been ``No
    write since last change'' even if the  buffer  had  not
    previously been modified.
9
( 1 , $ ) wwwwrrrriiiitttteeee>>>>>>>> _f_i_l_e                  abbr: wwww>>>>>>>>

    Writes the buffer contents at the end  of  an  existing
    file.

9
wwww!!!! _n_a_m_e

    Overrides the checking of the normal _w_r_i_t_e command, and
    will write to any file which the system permits.
9

9_________________________
* The editor writes to a file only if it is the current
file  and  is _e_d_i_t_e_d, if the file does not exist, or if
the file is actually a teletype,  /_d_e_v/_t_t_y,  /_d_e_v/_n_u_l_l.
Otherwise,  you  must give the variant form wwww!!!! to force
the write.




                    September 1, 19101





Ex Reference Manual                                USD:16-19


( 1 , $ ) wwww  !!!!_c_o_m_m_a_n_d

    Writes the specified  lines  into  _c_o_m_m_a_n_d.   Note  the
    difference  between  wwww!!!! which overrides checks and wwww  !!!!
    which writes to a command.
9
wwwwqqqq _n_a_m_e

    Like a _w_r_i_t_e and then a _q_u_i_t command.
9
wwwwqqqq!!!! _n_a_m_e

    The variant overrides checking on  the  sensibility  of
    the _w_r_i_t_e command, as wwww!!!! does.
9
xxxxiiiitttt _n_a_m_e

    If any changes have been made and not  written,  writes
    the buffer out.  Then, in any case, quits.
9
( .... , .... )yyyyaaaannnnkkkk _b_u_f_f_e_r _c_o_u_n_t              abbr: yyyyaaaa

    Places the specified lines in  the  named  _b_u_f_f_e_r,  for
    later  retrieval  via _p_u_t.  If no buffer name is speci-
    fied, the lines go to a more volatile  place;  see  the
    _p_u_t command description.
9
( ....++++1111 ) zzzz _c_o_u_n_t

    Print the next _c_o_u_n_t lines, default _w_i_n_d_o_w.
9
( .... ) zzzz _t_y_p_e _c_o_u_n_t

    Prints a window of text with the specified line at  the
    top.   If _t_y_p_e is `-' the line is placed at the bottom;
    a `....' causes the line to be placed in the  center.*   A
    count  gives the number of lines to be displayed rather
    than double the number specified by the _s_c_r_o_l_l  option.
    On  a  CRT  the screen is cleared before display begins
    unless a count which is less than the  screen  size  is
    given.   The  current  line  is  left  at the last line
    printed.
_________________________
* Forms `z=' and  `z|^'  also  exist;  `z='  places  the
current  line in the center, surrounds it with lines of
`-' characters and leaves  the  current  line  at  this
line.   The  form  `z|^'  prints  the window before `z-'
would.  The characters `+', `|^' and `-' may be repeated
for cumulative effect.  On some v2 editors, no _t_y_p_e may
be given.




                    September 1, 19101





USD:16-20                                Ex Reference Manual


!!!! _c_o_m_m_a_n_d

    The remainder of the line after the  `!'  character  is
    sent  to  a  shell  to be executed.  Within the text of
    _c_o_m_m_a_n_d 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.  The current line is unchanged by this command.

    If there has been ``[No write]'' of the buffer contents
    since  the  last  change  to the editing buffer, then a
    diagnostic will be printed before the command  is  exe-
    cuted  as  a warning.  A single `!' is printed when the
    command completes.
9
( _a_d_d_r , _a_d_d_r ) !!!! _c_o_m_m_a_n_d

    Takes the specified address range and  supplies  it  as
    standard  input  to  _c_o_m_m_a_n_d; the resulting output then
    replaces the input lines.
9
( $ ) ====

    Prints the line number  of  the  addressed  line.   The
    current line is unchanged.
9
( .... , .... ) >>>> _c_o_u_n_t _f_l_a_g_s
( .... , .... ) <<<< _c_o_u_n_t _f_l_a_g_s

    Perform intelligent shifting on the specified lines;  <<<<
    shifts  left  and >>>> shift right.  The quantity of shift
    is  determined  by  the  _s_h_i_f_t_w_i_d_t_h  option   and   the
    repetition  of the specification character.  Only white
    space  (blanks  and  tabs)  is  shifted;  no  non-white
    characters  are discarded in a left-shift.  The current
    line becomes the last line which  changed  due  to  the
    shifting.
9
^^^^DDDD

    An end-of-file from a terminal  input  scrolls  through
    the  file.  The _s_c_r_o_l_l option specifies the size of the
    scroll, normally a half screen of text.
9
( ....+1 , ....+1 )
( ....+1 , ....+1 ) |

    An address alone  causes  the  addressed  lines  to  be
    printed.   A  blank  line  prints  the next line in the
    file.


9                     September 1, 19101





Ex Reference Manual                                USD:16-21


( .... , .... ) &&&& _o_p_t_i_o_n_s _c_o_u_n_t _f_l_a_g_s

    Repeats the previous _s_u_b_s_t_i_t_u_t_e command.
9
( .... , .... ) ~~~~ _o_p_t_i_o_n_s _c_o_u_n_t _f_l_a_g_s

    Replaces the previous regular expression with the  pre-
    vious replacement pattern from a substitution.

_8.  _R_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n_s _a_n_d _s_u_b_s_t_i_t_u_t_e _r_e_p_l_a_c_e_m_e_n_t _p_a_t_t_e_r_n_s

_8._1.  _R_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n_s

    A regular expression specifies  a  set  of  strings  of
characters.   A  member of this set of strings is said to be
_m_a_t_c_h_e_d by the regular expression.  _E_x remembers two  previ-
ous  regular  expressions:   the previous regular expression
used in  a  _s_u_b_s_t_i_t_u_t_e  command  and  the  previous  regular
expression used elsewhere (referred to as the previous _s_c_a_n_-
_n_i_n_g regular expression.)  The previous  regular  expression
can always be referred to by a null _r_e, e.g. `//' or `??'.

_8._2.  _M_a_g_i_c _a_n_d _n_o_m_a_g_i_c

    The regular expressions allowed by _e_x  are  constructed
in  one  of  two  ways depending on the setting of the _m_a_g_i_c
option.  The _e_x and _v_i default setting of _m_a_g_i_c gives  quick
access  to  a powerful set of regular expression metacharac-
ters.  The disadvantage of  _m_a_g_i_c  is  that  the  user  must
remember  that  these  metacharacters  are _m_a_g_i_c and precede
them with the character `\'  to  use  them  as  ``ordinary''
characters.   With  _n_o_m_a_g_i_c,  the  default for _e_d_i_t, regular
expressions are much simpler, there being only two metachar-
acters.   The  power  of  the  other metacharacters is still
available by preceding the (now) ordinary character  with  a
`\'.  Note that `\' is thus always a metacharacter.

    The remainder of the discussion of regular  expressions
assumes that that the setting of this option is _m_a_g_i_c.|-

_8._3.  _B_a_s_i_c _r_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n _s_u_m_m_a_r_y

    The following basic constructs are  used  to  construct
_m_a_g_i_c mode regular expressions.
9_________________________
|- To discern what is true with _n_o_m_a_g_i_c it  suffices  to
remember  that the only special characters in this case
will be `|^' at the beginning of a  regular  expression,
`$'  at the end of a regular expression, and `\'.  With
_n_o_m_a_g_i_c the characters `~'  and  `&'  also  lose  their
special  meanings related to the replacement pattern of
a substitute.




                    September 1, 19101





USD:16-22                                Ex Reference Manual


_c_h_a_r           An ordinary character  matches  itself.   The
              characters  `|^'  at  the beginning of a line,
              `$' at the end of line, `*' as any  character
              other  than the first, `.', `\', `[', and `~'
              are  not  ordinary  characters  and  must  be
              escaped  (preceded)  by  `\' to be treated as
              such.

||||^^^^              At the beginning  of  a  pattern  forces  the
              match  to  succeed only at the beginning of a
              line.

$$$$              At the end of a regular expression forces the
              match to succeed only at the end of the line.

...              Matches any single character except the  new-
              line character.

\\\\<<<<             Forces the match to occur only at the  begin-
              ning  of a ``variable'' or ``word''; that is,
              either at the beginning of a  line,  or  just
              before  a  letter,  digit,  or  underline and
              after a character not one of these.

\\\\>>>>             Similar to `\<', but matching the  end  of  a
              ``variable'' or ``word'', i.e. either the end
              of the line or before character which is nei-
              ther a letter, nor a digit, nor the underline
              character.

[[[[_s_t_r_i_n_g]       Matches any (single) character in  the  class
              defined by _s_t_r_i_n_g.  Most characters in _s_t_r_i_n_g
              define  themselves.   A  pair  of  characters
              separated by `-' in _s_t_r_i_n_g defines the set of
              characters collating  between  the  specified
              lower  and  upper  bounds,  thus `[a-z]' as a
              regular  expression  matches   any   (single)
              lower-case letter.  If the first character of
              _s_t_r_i_n_g is an `|^' then the  construct  matches
              those  characters  which  it  otherwise would
              not; thus `[|^a-z]'  matches  anything  but  a
              lower-case  letter (and of course a newline).
              To place any of the characters `|^',  `[',  or
              `-'  in  _s_t_r_i_n_g  you  must escape them with a
              preceding `\'.

_8._4.  _C_o_m_b_i_n_i_n_g _r_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n _p_r_i_m_i_t_i_v_e_s

    The concatenation of two  regular  expressions  matches
the  leftmost  and  then longest string which can be divided
with the first piece matching the first  regular  expression
and  the second piece matching the second.  Any of the (sin-
gle character matching) regular expressions mentioned  above
may  be  followed  by  the  character  `*' to form a regular



                    September 1, 19101





Ex Reference Manual                                USD:16-23


expression which matches any number of adjacent  occurrences
(including  0)  of characters matched by the regular expres-
sion it follows.

    The character `~' may be used in a regular  expression,
and  matches  the text which defined the replacement part of
the last _s_u_b_s_t_i_t_u_t_e command.  A regular  expression  may  be
enclosed  between  the  sequences  `\('  and  `\)' with side
effects in the _s_u_b_s_t_i_t_u_t_e replacement patterns.

_8._5.  _S_u_b_s_t_i_t_u_t_e _r_e_p_l_a_c_e_m_e_n_t _p_a_t_t_e_r_n_s

    The basic metacharacters for  the  replacement  pattern
are  `&'  and  `~';  these  are  given as `\&' and `\~' when
_n_o_m_a_g_i_c is set.  Each instance of `&'  is  replaced  by  the
characters  which the regular expression matched.  The meta-
character `~' stands, in the replacement  pattern,  for  the
defining text of the previous replacement pattern.

    Other metasequences possible in the replacement pattern
are  always  introduced  by the escaping character `\'.  The
sequence `\_n' is replaced by the text matched  by  the  _n-th
regular subexpression enclosed between `\(' and  `\)'.|-  The
sequences  `\u'  and  `\l'  cause  the immediately following
character in the replacement to be converted  to  upper-  or
lower-case  respectively if this character is a letter.  The
sequences `\U' and `\L'  turn  such  conversion  on,  either
until  `\E'  or `\e' is encountered, or until the end of the
replacement pattern.

_9.  _O_p_t_i_o_n _d_e_s_c_r_i_p_t_i_o_n_s

9
aaaauuuuttttooooiiiinnnnddddeeeennnntttt, aaaaiiii                default: noai

    Can be used to ease the preparation of structured  pro-
    gram  text.  At the beginning of each _a_p_p_e_n_d, _c_h_a_n_g_e or
    _i_n_s_e_r_t command or when a new line is _o_p_e_n_e_d or  created
    by  an  _a_p_p_e_n_d, _c_h_a_n_g_e, _i_n_s_e_r_t, or _s_u_b_s_t_i_t_u_t_e operation
    within _o_p_e_n or _v_i_s_u_a_l mode, _e_x looks at the line  being
    appended  after,  the  first  line  changed or the line
    inserted before and  calculates  the  amount  of  white
    space  at  the  start  of the line.  It then aligns the
    cursor at the level of indentation so determined.

    If the user then types lines of text in, they will con-
    tinue to be justified at the displayed indenting level.
    If more white space is typed  at  the  beginning  of  a
    line,  the  following  line will start aligned with the
_________________________
|-  When  nested,   parenthesized   subexpressions   are
present,  _n  is  determined  by counting occurrences of
`\(' starting from the left.
9


                    September 1, 19101





USD:16-24                                Ex Reference Manual


    first non-white character of  the  previous  line.   To
    back  the  cursor  up to the preceding tab stop one can
    hit ^^^^DDDD.  The tab stops going backwards are  defined  at
    multiples  of  the _s_h_i_f_t_w_i_d_t_h option.  You _c_a_n_n_o_t back-
    space over the indent, except by sending an end-of-file
    with a ^^^^DDDD.

    Specially processed in this mode  is  a  line  with  no
    characters  added  to it, which turns into a completely
    blank line (the white space provided for the _a_u_t_o_i_n_d_e_n_t
    is  discarded.)   Also specially processed in this mode
    are lines beginning with an `|^'  and  immediately  fol-
    lowed  by  a  ^^^^DDDD.   This causes the input to be reposi-
    tioned at the beginning of the line, but retaining  the
    previous  indent  for  the next line.  Similarly, a `0'
    followed by a  ^^^^DDDD  repositions  at  the  beginning  but
    without retaining the previous indent.

    _A_u_t_o_i_n_d_e_n_t doesn't happen in _g_l_o_b_a_l  commands  or  when
    the input is not a terminal.
9
aaaauuuuttttoooopppprrrriiiinnnntttt, aaaapppp                 default: ap

    Causes the  current  line  to  be  printed  after  each
    _d_e_l_e_t_e,  _c_o_p_y, _j_o_i_n, _m_o_v_e, _s_u_b_s_t_i_t_u_t_e, _t, _u_n_d_o or shift
    command.  This has  the  same  effect  as  supplying  a
    trailing  `p'  to  each  such  command.   _A_u_t_o_p_r_i_n_t  is
    suppressed in globals, and only applies to the last  of
    many commands on a line.
9
aaaauuuuttttoooowwwwrrrriiiitttteeee, aaaawwww                 default: noaw

    Causes the contents of the buffer to be written to  the
    current  file  if you have modified it and give a _n_e_x_t,
    _r_e_w_i_n_d, _s_t_o_p, _t_a_g, or  !   command,  or  a  ^^^^||||^^^^  (switch
    files)  or ^^^^]]]] (tag goto) command in _v_i_s_u_a_l.  Note, that
    the _e_d_i_t and _e_x commands do  _n_o_t  autowrite.   In  each
    case,  there  is  an  equivalent  way of switching when
    autowrite is set to avoid the _a_u_t_o_w_r_i_t_e (_e_d_i_t for _n_e_x_t,
    _r_e_w_i_n_d!   for  .I  rewind  , _s_t_o_p!  for _s_t_o_p, _t_a_g!  for
    _t_a_g, _s_h_e_l_l for !, and ::::eeee ####  and  a  ::::ttttaaaa!!!!  command  from
    within _v_i_s_u_a_l).
9
bbbbeeeeaaaauuuuttttiiiiffffyyyy, bbbbffff                  default: nobeautify

    Causes all control characters except tab,  newline  and
    form-feed  to be discarded from the input.  A complaint
    is registered the first time a backspace  character  is
    discarded.  _B_e_a_u_t_i_f_y does not apply to command input.
9





                    September 1, 19101





Ex Reference Manual                                USD:16-25


ddddiiiirrrreeeeccccttttoooorrrryyyy, ddddiiiirrrr                default: dir=/tmp

    Specifies the directory in which _e_x places  its  buffer
    file.  If this directory in not writable, then the edi-
    tor will exit abruptly when it  fails  to  be  able  to
    create its buffer there.
9
eeeeddddccccoooommmmppppaaaattttiiiibbbblllleeee                  default: noedcompatible

    Causes the presence of absence of _g and _c  suffixes  on
    substitute commands to be remembered, and to be toggled
    by repeating the suffices.  The suffix _r makes the sub-
    stitution be as in the ~ command, instead of like &.
9
eeeerrrrrrrroooorrrrbbbbeeeellllllllssss, eeeebbbb                default: noeb

    Error messages are preceded by a  bell.*   If  possible
    the  editor  always places the error message in a stan-
    dout mode of  the  terminal  (such  as  inverse  video)
    instead of ringing the bell.
9
hhhhaaaarrrrddddttttaaaabbbbssss, hhhhtttt                  default: ht=8

    Gives the boundaries on which  terminal  hardware  tabs
    are set (or on which the system expands tabs).
9
iiiiggggnnnnoooorrrreeeeccccaaaasssseeee, iiiicccc                default: noic

    All upper case characters in the  text  are  mapped  to
    lower  case  in  regular expression matching.  In addi-
    tion, all upper case characters in regular  expressions
    are  mapped  to  lower  case  except in character class
    specifications.
9
lllliiiisssspppp                          default: nolisp

    _A_u_t_o_i_n_d_e_n_t indents appropriately for _l_i_s_p code, and the
    (((( )))) {{{{ }}}} [[[[[[[[ and ]]]]]]]] commands in _o_p_e_n and _v_i_s_u_a_l are modi-
    fied to have meaning for _l_i_s_p.
9
lllliiiisssstttt                          default: nolist

    All printed lines will be  displayed  (more)  unambigu-
    ously,  showing  tabs  and  end-of-lines as in the _l_i_s_t
    command.
9
9_________________________
* Bell ringing in _o_p_e_n and  _v_i_s_u_a_l  on  errors  is  not
suppressed by setting _n_o_e_b.




                    September 1, 19101





USD:16-26                                Ex Reference Manual


mmmmaaaaggggiiiicccc                         default: magic for _e_x and _v_i|-

    If _n_o_m_a_g_i_c is set, the  number  of  regular  expression
    metacharacters  is  greatly  reduced, with only `|^' and
    `$' having special effects.  In addition the  metachar-
    acters  `~'  and  `&'  of  the  replacement pattern are
    treated as normal characters.  All the normal metachar-
    acters may be made _m_a_g_i_c when _n_o_m_a_g_i_c is set by preced-
    ing them with a `\'.
9
mmmmeeeessssgggg                          default: mesg

    Causes write permission to be turned off to the  termi-
    nal while you are in visual mode, if _n_o_m_e_s_g is set.
9
mmmmooooddddeeeelllliiiinnnneeee                      default: nomodeline

    If _m_o_d_e_l_i_n_e is set, then the first 5 lines and the last
    five  lines  of the file will be checked for ex command
    lines and the comands issued.  To be  recognized  as  a
    command line, the line must have the string _e_x:  or _v_i:
    preceeded by a tab or a space.  This string may be any-
    where  in  the line and anything after the :  is inter-
    peted as editor commands.  This option defaults to  off
    because of unexpected behavior when editting files such
    as /_e_t_c/_p_a_s_s_w_d.
9
nnnnuuuummmmbbbbeeeerrrr,,,, nnnnuuuu                    default: nonumber

    Causes all output lines to be printed with  their  line
    numbers.   In addition each input line will be prompted
    for by supplying the line number it will have.
9
ooooppppeeeennnn                          default: open

    If _n_o_o_p_e_n, the commands _o_p_e_n and _v_i_s_u_a_l are not permit-
    ted.  This is set for _e_d_i_t to prevent confusion result-
    ing from accidental entry to open or visual mode.
9
ooooppppttttiiiimmmmiiiizzzzeeee,,,, oooopppptttt                 default: optimize

    Throughput of text is expedited by setting the terminal
    to not do automatic carriage returns when printing more
    than one (logical) line  of  output,  greatly  speeding
    output  on  terminals  without addressable cursors when
    text with leading white space is printed.
9

_________________________
|- _N_o_m_a_g_i_c for _e_d_i_t.




                    September 1, 19101





Ex Reference Manual                                USD:16-27


ppppaaaarrrraaaaggggrrrraaaapppphhhhssss,,,, ppppaaaarrrraaaa              default: para=IPLPPPQPP LIbp

    Specifies the paragraphs for the {{{{ and }}}} operations  in
    _o_p_e_n  and  _v_i_s_u_a_l.   The  pairs  of  characters  in the
    option's value are the names of the macros which  start
    paragraphs.
9
pppprrrroooommmmpppptttt                        default: prompt

    Command mode input is prompted for with a `:'.
9
rrrreeeeddddrrrraaaawwww                        default: noredraw

    The editor simulates (using great amounts  of  output),
    an intelligent terminal on a dumb terminal (e.g. during
    insertions in _v_i_s_u_a_l the characters to the right of the
    cursor  position  are refreshed as each input character
    is typed.)  Useful only at very high speed.
9
rrrreeeemmmmaaaapppp                         default: remap

    If on, macros  are  repeatedly  tried  until  they  are
    unchanged.   For example, if _o is mapped to _O, and _O is
    mapped to _I, then if _r_e_m_a_p is set, _o will map to _I, but
    if _n_o_r_e_m_a_p is set, it will map to _O.
9
rrrreeeeppppoooorrrrtttt                        default: report=5|-

    Specifies a threshold for feedback from commands.   Any
    command  which  modifies more than the specified number
    of lines will provide feedback as to the scope  of  its
    changes.   For commands such as _g_l_o_b_a_l, _o_p_e_n, _u_n_d_o, and
    _v_i_s_u_a_l which have potentially more far reaching  scope,
    the  net change in the number of lines in the buffer is
    presented at the end of the command,  subject  to  this
    same threshold.  Thus notification is suppressed during
    a _g_l_o_b_a_l command on the individual commands performed.
9
ssssccccrrrroooollllllll                        default: scroll=1/2 window

    Determines the number of logical lines scrolled when an
    end-of-file  is  received from a terminal input in com-
    mand mode, and the number of lines printed by a command
    mode _z command (double the value of _s_c_r_o_l_l).
9
sssseeeeccccttttiiiioooonnnnssss                      default: sections=SHNHH HU

    Specifies  the  section  macros  for  the  [[[[[[[[  and   ]]]]]]]]
_________________________
|- 2 for _e_d_i_t.




                    September 1, 19101





USD:16-28                                Ex Reference Manual


    operations in _o_p_e_n and _v_i_s_u_a_l.  The pairs of characters
    in  the  options's  value  are  the names of the macros
    which start paragraphs.
9
sssshhhheeeellllllll, sssshhhh                     default: sh=/bin/sh

    Gives the path name of the shell forked for  the  shell
    escape  command  `!',  and  by  the _s_h_e_l_l command.  The
    default is taken from  SHELL  in  the  environment,  if
    present.
9
sssshhhhiiiiffffttttwwwwiiiiddddtttthhhh, sssswwww                default: sw=8

    Gives the width a software tab stop,  used  in  reverse
    tabbing  with  ^^^^DDDD when using _a_u_t_o_i_n_d_e_n_t to append text,
    and by the shift commands.
9
sssshhhhoooowwwwmmmmaaaattttcccchhhh,,,, ssssmmmm                 default: nosm

    In _o_p_e_n and _v_i_s_u_a_l mode, when a )))) or }}}} is  typed,  move
    the  cursor  to  the  matching (((( or {{{{ for one second if
    this matching character is on  the  screen.   Extremely
    useful with _l_i_s_p.
9
sssslllloooowwwwooooppppeeeennnn,,,, sssslllloooowwww                terminal dependent

    Affects the display  algorithm  used  in  _v_i_s_u_a_l  mode,
    holding  off  display updating during input of new text
    to improve throughput when the terminal in use is  both
    slow and unintelligent.  See _A_n _I_n_t_r_o_d_u_c_t_i_o_n _t_o _D_i_s_p_l_a_y
    _E_d_i_t_i_n_g _w_i_t_h _V_i for more details.
9
ttttaaaabbbbssssttttoooopppp,,,, ttttssss                   default: ts=8

    The editor expands tabs in the  input  file  to  be  on
    _t_a_b_s_t_o_p boundaries for the purposes of display.
9
ttttaaaagggglllleeeennnnggggtttthhhh,,,, ttttllll                 default: tl=0

    Tags are not significant beyond this  many  characters.
    A value of zero (the default) means that all characters
    are significant.
9
ttttaaaaggggssss                          default:             tags=tags
/usr/lib/tags

    A path of files to be used as tag  files  for  the  _t_a_g
    command.  A requested tag is searched for in the speci-
    fied files, sequentially.   By  default,  files  called
    _t_a_g_s  are  searched for in the current directory and in
    /usr/lib (a master file for the entire system).


9                     September 1, 19101





Ex Reference Manual                                USD:16-29


tttteeeerrrrmmmm                          from environment TERM

    The terminal type of the output device.
9
tttteeeerrrrsssseeee                         default: noterse

    Shorter error diagnostics are produced for the  experi-
    enced user.
9
wwwwaaaarrrrnnnn                          default: warn

    Warn if there has been `[No write since  last  change]'
    before a `!'  command escape.
9
wwwwiiiinnnnddddoooowwww                        default:  window=speed  depen-
dent

    The number of lines in a text window in the _v_i_s_u_a_l com-
    mand.   The  default  is  8 at slow speeds (600 baud or
    less), 16 at medium speed (1200  baud),  and  the  full
    screen (minus one line) at higher speeds.
9
wwww333300000000,,,, wwww1111222200000000,,,, wwww9999666600000000

    These are not true options but set _w_i_n_d_o_w only  if  the
    speed  is  slow  (300),  medium (1200), or high (9600),
    respectively.  They are suitable for an EXINIT and make
    it easy to change the 8/16/full screen rule.
9
wwwwrrrraaaappppssssccccaaaannnn, wwwwssss                  default: ws

    Searches using the regular  expressions  in  addressing
    will wrap around past the end of the file.
9
wwwwrrrraaaappppmmmmaaaarrrrggggiiiinnnn, wwwwmmmm                default: wm=0

    Defines a margin for automatic wrapover of text  during
    input in _o_p_e_n and _v_i_s_u_a_l modes.  See _A_n _I_n_t_r_o_d_u_c_t_i_o_n _t_o
    _T_e_x_t _E_d_i_t_i_n_g _w_i_t_h _V_i for details.
9
wwwwrrrriiiitttteeeeaaaannnnyyyy, wwwwaaaa                  default: nowa

    Inhibit the checks normally made before _w_r_i_t_e commands,
    allowing  a  write to any file which the system protec-
    tion mechanism will allow.

_1_0.  _L_i_m_i_t_a_t_i_o_n_s

    Editor limits that the user is likely to encounter  are
as  follows:   1024  characters per line, 256 characters per
global command list,  128  characters  per  file  name,  128


9                     September 1, 19101





USD:16-30                                Ex Reference Manual


characters in the previous inserted and deleted text in _o_p_e_n
or _v_i_s_u_a_l, 100 characters in  a  shell  escape  command,  63
characters in a string valued option, and 30 characters in a
tag name, and a  limit  of  250000  lines  in  the  file  is
silently enforced.

    The _v_i_s_u_a_l implementation limits the number  of  macros
defined  with  map to 32, and the total number of characters
in macros to be less than 512.


_A_c_k_n_o_w_l_e_d_g_m_e_n_t_s.  Chuck Haley  contributed  greatly  to  the
early  development  of  _e_x.   Bruce  Englar  encouraged  the
redesign which led to _e_x version 1.  Bill Joy wrote versions
1  and 2.0 through 2.7, and created the framework that users
see in the present editor.  Mark  Horton  added  macros  and
other features and made the editor work on a large number of
terminals and Unix systems.







































                    September 1, 19101