home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / riscbsd / datafile / usd / 16_ex / ex_rm_txt next >
Encoding:
Text File  |  1996-10-12  |  60.6 KB  |  2,047 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                     Ex Reference Manual
  11.                         Version 3.7
  12.  
  13.                         William Joy
  14.                         Mark Horton
  15.                  Computer Science Division
  16.  Department of Electrical Engineering and Computer Science
  17.              University of California, Berkeley
  18.                     Berkeley, Ca.  94720
  19.  
  20.  
  21.                           ABSTRACT
  22.  
  23.  
  24.           Ex  a  line  oriented text editor, which sup-
  25.      ports both command and display  oriented  editing.
  26.      This  reference  manual describes the command ori-
  27.      ented part of ex; the display editing features  of
  28.      ex  are  described  in  An Introduction to Display
  29.      Editing with Vi.  Other documents about the editor
  30.      include  the  introduction  Edit:  A tutorial, the
  31.      Ex/edit Command Summary, and a Vi Quick  Reference
  32.      card.
  33.  
  34.  
  35. 1.  Starting ex
  36.  
  37.      Each instance of the editor has a set of options, which
  38. can  be  set  to tailor it to your liking.  The command edit
  39. invokes a version of ex designed for more casual  or  begin-
  40. ning users by changing the default settings of some of these
  41. options.  To  simplify  the  description  which  follows  we
  42. assume the default settings of the options.
  43.  
  44.      When  invoked, ex determines the terminal type from the
  45. TERM variable in the environment.  It  there  is  a  TERMCAP
  46. variable  in  the  environment, and the type of the terminal
  47. described  there  matches  the  TERM  variable,  then   that
  48. description  is used.  Also if the TERMCAP variable contains
  49. a pathname (beginning with a /) then the  editor  will  seek
  50. the  description  of  the terminal in that file (rather than
  51. the default /etc/termcap).  If there is a variable EXINIT in
  52. the  environment,  then the editor will execute the commands
  53. in that variable, otherwise if there is a file .exrc in your
  54. HOME  directory ex reads commands from that file, simulating
  55. a source command.  Option setting commands placed in  EXINIT
  56. -----------
  57. The  financial  support of an IBM Graduate Fellow-
  58. ship and the  National  Science  Foundation  under
  59. grants  MCS74-07644-A03  and MCS78-07291 is grate-
  60. fully acknowledged.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. USD:16-2                                 Ex Reference Manual
  71.  
  72.  
  73. or .exrc will be executed before each editor session.
  74.  
  75.      A command to enter ex has the following prototype:-
  76.  
  77.      ex [ - ] [ -v ] [ -t tag ] [ -r ] [ -l ] [ -wn ] [ -x ] [ -R ] [ +command ] name ...
  78.  
  79. The most common case edits a single file  with  no  options,
  80. i.e.:
  81.  
  82.      ex name
  83.  
  84. The - command line option option suppresses all interactive-
  85. user feedback and is useful in processing editor scripts  in
  86. command  files.   The  -v  option  is equivalent to using vi
  87. rather than ex.  The -t option is equivalent to  an  initial
  88. tag  command,  editing the file containing the tag and posi-
  89. tioning the editor at its definition.  The -r option is used
  90. in  recovering  after  an editor or system crash, retrieving
  91. the last saved version of the named file or, if no  file  is
  92. specified, typing a list of saved files.  The -l option sets
  93. up for editing LISP, setting the showmatch and lisp options.
  94. The -w option sets the default window size to n, and is use-
  95. ful on dialups to start in small  windows.   The  -x  option
  96. causes  ex to prompt for a key, which is used to encrypt and
  97. decrypt the contents of the file, which  should  already  be
  98. encrypted  using  the same key, see crypt(1).  The -R option
  99. sets the readonly option at the start.  Name arguments indi-
  100. cate  files  to be edited.  An argument of the form +command
  101. indicates that the editor  should  begin  by  executing  the
  102. specified  command.  If command is omitted, then it defaults
  103. to ``$'', positioning the editor at the  last  line  of  the
  104. first  file initially.  Other useful commands here are scan-
  105. ning patterns of the form ``/pat''  or  line  numbers,  e.g.
  106. ``+100'' starting at line 100.
  107.  
  108. 2.  File manipulation
  109.  
  110. 2.1.  Current file
  111.  
  112.      Ex  is  normally editing the contents of a single file,
  113. whose name is recorded in the current file  name.   Ex  per-
  114. forms  all editing actions in a buffer (actually a temporary
  115. file) into which the text of the  file  is  initially  read.
  116. Changes  made to the buffer have no effect on the file being
  117. edited unless and until the buffer contents are written  out
  118. to the file with a write command.  After the buffer contents
  119. are written, the previous contents of the written  file  are
  120. no  longer  accessible.   When  a  file  is edited, its name
  121. becomes the current file name, and  its  contents  are  read
  122. into the buffer.
  123.  
  124. -----------
  125. -  Brackets  `['  `]' surround optional parameters
  126. here.
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. Ex Reference Manual                                 USD:16-3
  137.  
  138.  
  139.      The  current  file  is  almost  always considered to be
  140. edited.  This means that the contents of the buffer are log-
  141. ically connected with the current file name, so that writing
  142. the current buffer contents  onto  that  file,  even  if  it
  143. exists,  is a reasonable action.  If the current file is not
  144. edited then ex will not normally write on it if  it  already
  145. exists.*
  146.  
  147. 2.2.  Alternate file
  148.  
  149.      Each time a new value is  given  to  the  current  file
  150. name,  the previous current file name is saved as the alter-
  151. nate file name.  Similarly if a file is mentioned  but  does
  152. not  become  the  current file, it is saved as the alternate
  153. file name.
  154.  
  155. 2.3.  Filename expansion
  156.  
  157.      Filenames within the editor may be specified using  the
  158. normal  shell expansion conventions.  In addition, the char-
  159. acter `%' in filenames is replaced by the current file  name
  160. and the character `#' by the alternate file name.-
  161.  
  162. 2.4.  Multiple files and named buffers
  163.  
  164.      If more than one file is given  on  the  command  line,
  165. then  the  first  file  is  edited  as described above.  The
  166. remaining arguments are placed with the first  file  in  the
  167. argument  list.   The current argument list may be displayed
  168. with the args command.  The next file in the  argument  list
  169. may  be edited with the next command.  The argument list may
  170. also be respecified by specifying a list  of  names  to  the
  171. next  command.  These names are expanded, the resulting list
  172. of names becomes the new argument list,  and  ex  edits  the
  173. first file on the list.
  174.  
  175.      For saving blocks of text while editing, and especially
  176. when editing more than one file, ex has  a  group  of  named
  177. buffers.   These  are  similar  to the normal buffer, except
  178. that only a limited number of operations  are  available  on
  179. them.  The buffers have names a through z.=
  180.  
  181.  
  182. -----------
  183. *  The  file  command will say ``[Not edited]'' if
  184. the current file is not considered edited.
  185. -  This makes it easy to deal alternately with two
  186. files and eliminates the  need  for  retyping  the
  187. name  supplied on an edit command after a No write
  188. since last change diagnostic is received.
  189. = It is also possible to refer to A through Z; the
  190. upper case buffers are the same as the  lower  but
  191. commands  append  to  named  buffers  rather  than
  192. replacing if upper case names are used.
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. USD:16-4                                 Ex Reference Manual
  203.  
  204.  
  205. 2.5.  Read only
  206.  
  207.      It is possible to use ex in read only mode to  look  at
  208. files  that  you  have no intention of modifying.  This mode
  209. protects you from accidently  overwriting  the  file.   Read
  210. only  mode is on when the readonly option is set.  It can be
  211. turned on with the -R command line option, by the view  com-
  212. mand line invocation, or by setting the readonly option.  It
  213. can be cleared by setting noreadonly.   It  is  possible  to
  214. write,  even while in read only mode, by indicating that you
  215. really know what you are doing.  You can write to a  differ-
  216. ent file, or can use the ! form of write, even while in read
  217. only mode.
  218.  
  219. 3.  Exceptional Conditions
  220.  
  221. 3.1.  Errors and interrupts
  222.  
  223.      When errors occur ex (optionally)  rings  the  terminal
  224. bell  and,  in any case, prints an error diagnostic.  If the
  225. primary input is from a file, editor processing will  termi-
  226. nate.   If  an  interrupt  signal  is  received,  ex  prints
  227. ``Interrupt'' and returns to its command level.  If the pri-
  228. mary input is a file, then ex will exit when this occurs.
  229.  
  230. 3.2.  Recovering from hangups and crashes
  231.  
  232.      If  a hangup signal is received and the buffer has been
  233. modified since it was last written out,  or  if  the  system
  234. crashes, either the editor (in the first case) or the system
  235. (after it reboots in the second) will  attempt  to  preserve
  236. the  buffer.  The next time you log in you should be able to
  237. recover the work you were doing, losing at most a few  lines
  238. of  changes  from the last point before the hangup or editor
  239. crash.  To recover a file you can use the -r option.  If you
  240. were  editing the file resume, then you should change to the
  241. directory where you were when the crash occurred, giving the
  242. command
  243.  
  244.      ex -r resume
  245.  
  246. After checking that the retrieved file is indeed ok, you can
  247. write it over the previous contents of that file.
  248.  
  249.      You will normally get mail from the system telling  you
  250. when a file has been saved after a crash.  The command
  251.  
  252.      ex -r
  253.  
  254. will  print  a  list  of the files which have been saved for
  255. you.  (In the case of a hangup, the file will not appear  in
  256. the list, although it can be recovered.)
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. Ex Reference Manual                                 USD:16-5
  269.  
  270.  
  271. 4.  Editing modes
  272.  
  273.      Ex  has  five distinct modes.  The primary mode is com-
  274. mand mode.  Commands are entered in command mode when a  `:'
  275. prompt  is  present,  and  are executed each time a complete
  276. line is sent.  In text input mode ex gathers input lines and
  277. places  them  in  the  file.  The append, insert, and change
  278. commands use text input mode.  No prompt is printed when you
  279. are  in  text input mode.  This mode is left by typing a `.'
  280. alone at the beginning of a line, and command mode  resumes.
  281.  
  282.      The last three modes are open and visual modes, entered
  283. by the commands of the  same  name,  and,  within  open  and
  284. visual  modes  text  insertion  mode.  Open and visual modes
  285. allow local editing operations to be performed on  the  text
  286. in  the  file.  The open command displays one line at a time
  287. on any terminal while visual works  on  CRT  terminals  with
  288. random  positioning  cursors, using the screen as a (single)
  289. window for file editing changes.  These modes are  described
  290. (only) in An Introduction to Display Editing with Vi.
  291.  
  292. 5.  Command structure
  293.  
  294.      Most  command names are English words, and initial pre-
  295. fixes of the words are acceptable abbreviations.  The  ambi-
  296. guity of abbreviations is resolved in favor of the more com-
  297. monly used commands.*
  298.  
  299. 5.1.  Command parameters
  300.  
  301.      Most commands accept prefix  addresses  specifying  the
  302. lines  in  the file upon which they are to have effect.  The
  303. forms of these addresses will be discussed below.  A  number
  304. of  commands  also  may take a trailing count specifying the
  305. number of lines to be involved in  the  command.-  Thus  the
  306. command  ``10p''  will  print  the  tenth line in the buffer
  307. while ``delete 5'' will delete five lines from  the  buffer,
  308. starting with the current line.
  309.  
  310.      Some  commands  take  other  information or parameters,
  311. this information always being given after the command name.=
  312.  
  313.  
  314.  
  315. -----------
  316. * As an example, the  command  substitute  can  be
  317. abbreviated   `s'  while  the  shortest  available
  318. abbreviation for the set command is `se'.
  319. - Counts are rounded down if necessary.
  320. =  Examples would be option names in a set command
  321. i.e. ``set number'', a file name in an  edit  com-
  322. mand,  a  regular  expression in a substitute com-
  323. mand, or a target address for a copy command, i.e.
  324. ``1,5 copy 25''.
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. USD:16-6                                 Ex Reference Manual
  335.  
  336.  
  337. 5.2.  Command variants
  338.  
  339.      A  number  of commands have two distinct variants.  The
  340. variant form of the command is invoked  by  placing  an  `!'
  341. immediately  after  the  command  name.  Some of the default
  342. variants may be controlled by options; in this case, the `!'
  343. serves to toggle the default.
  344.  
  345. 5.3.  Flags after commands
  346.  
  347.      The  characters  `#',  `p'  and `l' may be placed after
  348. many  commands.**   In this case, the command abbreviated by
  349. these characters is executed after  the  command  completes.
  350. Since  ex  normally  prints  the new current line after each
  351. change, `p' is rarely necessary.  Any number of `+'  or  `-'
  352. characters  may  also  be  given  with these flags.  If they
  353. appear, the specified offset is applied to the current  line
  354. value before the printing command is executed.
  355.  
  356. 5.4.  Comments
  357.  
  358.      It  is  possible  to  give  editor  commands  which are
  359. ignored.  This is useful when making complex editor  scripts
  360. for  which  comments  are desired.  The comment character is
  361. the double quote: ".  Any command line beginning with  "  is
  362. ignored.   Comments  beginning  with " may also be placed at
  363. the ends of commands, except in cases where  they  could  be
  364. confused  as  part of text (shell escapes and the substitute
  365. and map commands).
  366.  
  367. 5.5.  Multiple commands per line
  368.  
  369.      More than one command may be placed on a line by  sepa-
  370. rating  each  pair  of commands by a `|' character.  However
  371. the global commands, comments,  and  the  shell  escape  `!'
  372. must  be  the last command on a line, as they are not termi-
  373. nated by a `|'.
  374.  
  375. 5.6.  Reporting large changes
  376.  
  377.      Most commands which change the contents of  the  editor
  378. buffer  give  feedback  if the scope of the change exceeds a
  379. threshold given by the report option.  This  feedback  helps
  380. to  detect  undesirably  large  changes  so that they may be
  381. quickly and easily reversed with an  undo.   After  commands
  382. with  more  global effect such as global or visual, you will
  383. be informed if the net change in the number of lines in  the
  384. buffer during this command exceeds this threshold.
  385.  
  386.  
  387.  
  388. -----------
  389. ** A `p' or `l' must be preceded by a blank or tab
  390. except in the single special case `dp'.
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. Ex Reference Manual                                 USD:16-7
  401.  
  402.  
  403. 6.  Command addressing
  404.  
  405. 6.1.  Addressing primitives
  406.  
  407. .                   The  current  line.  Most commands leave
  408.                     the current line as the last line  which
  409.                     they  affect.   The  default address for
  410.                     most commands is the current line,  thus
  411.                     `.'  is rarely used alone as an address.
  412.  
  413. n                   The nth line  in  the  editor's  buffer,
  414.                     lines  being  numbered sequentially from
  415.                     1.
  416.  
  417. $                   The last line in the buffer.
  418.  
  419. %                   An abbreviation for ``1,$'', the  entire
  420.                     buffer.
  421.  
  422. +n -n               An offset relative to the current buffer
  423.                     line.-
  424.  
  425. /pat/ ?pat?         Scan forward and  backward  respectively
  426.                     for  a  line  containing  pat, a regular
  427.                     expression  (as  defined  below).    The
  428.                     scans  normally  wrap  around the end of
  429.                     the buffer.  If all that is  desired  is
  430.                     to  print  the next line containing pat,
  431.                     then the trailing / or ? may be omitted.
  432.                     If  pat  is omitted or explicitly empty,
  433.                     then the last regular expression  speci-
  434.                     fied is located.=
  435.  
  436. '' 'x               Before each non-relative motion  of  the
  437.                     current  line  `.', the previous current
  438.                     line is marked with a tag,  subsequently
  439.                     referred to as `'''.  This makes it easy
  440.                     to refer or return to this previous con-
  441.                     text.   Marks may also be established by
  442.                     the mark  command,  using  single  lower
  443.                     case  letters  x  and  the  marked lines
  444.                     referred to as `'x'.
  445.  
  446.  
  447.  
  448.  
  449. -----------
  450. - The forms `.+3' `+3' and `+++' are  all  equiva-
  451. lent;  if  the  current  line is line 100 they all
  452. address line 103.
  453. =  The forms \/ and \? scan using the last regular
  454. expression used in a scan; after a  substitute  //
  455. and  ??  would scan using the substitute's regular
  456. expression.
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. USD:16-8                                 Ex Reference Manual
  467.  
  468.  
  469. 6.2.  Combining addressing primitives
  470.  
  471.      Addresses to commands consist of a series of addressing
  472. primitives, separated by `,' or `;'.  Such address lists are
  473. evaluated left-to-right.  When addresses  are  separated  by
  474. `;'  the current line `.'  is set to the value of the previ-
  475. ous addressing expression before the next address is  inter-
  476. preted.   If  more  addresses  are  given  than  the command
  477. requires, then all but the last one or two are ignored.   If
  478. the  command  takes  two addresses, the first addressed line
  479. must precede the second in the buffer.-
  480.  
  481. 7.  Command descriptions
  482.  
  483.      The following form is a prototype for all ex commands:
  484.  
  485.      address command ! parameters count flags
  486.  
  487. All parts are optional; the degenerate  case  is  the  empty
  488. command  which prints the next line in the file.  For sanity
  489. with use from within visual mode, ex ignores a ``:'' preced-
  490. ing any command.
  491.  
  492.      In  the  following  command  descriptions,  the default
  493. addresses are shown in parentheses, which are not,  however,
  494. part of the command.
  495.  
  496.  
  497. abbreviate word rhs                     abbr: ab
  498.  
  499.      Add  the  named abbreviation to the current list.  When
  500.      in input mode in visual, if word is typed as a complete
  501.      word, it will be changed to rhs.
  502.  
  503.  
  504. ( . ) append                            abbr: a
  505. text
  506. .
  507.  
  508.      Reads  the input text and places it after the specified
  509.      line.  After the command, `.'  addresses the last  line
  510.      input or the specified line if no lines were input.  If
  511.      address `0' is given, text is placed at  the  beginning
  512.      of the buffer.
  513.  
  514.  
  515.  
  516.  
  517. -----------
  518. - Null address specifications are permitted  in  a
  519. list of addresses, the default in this case is the
  520. current line `.'; thus  `,100'  is  equivalent  to
  521. `.,100'.   It is an error to give a prefix address
  522. to a command which expects none.
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. Ex Reference Manual                                 USD:16-9
  533.  
  534.  
  535. a!
  536. text
  537. .
  538.  
  539.      The  variant flag to append toggles the setting for the
  540.      autoindent option during the input of text.
  541.  
  542.  
  543. args
  544.  
  545.      The members of the argument list are printed, with  the
  546.      current argument delimited by `[' and `]'.
  547.  
  548.  
  549. ( . , . ) change count                  abbr: c
  550. text
  551. .
  552.  
  553.      Replaces  the specified lines with the input text.  The
  554.      current line becomes the last line input; if  no  lines
  555.      were input it is left as for a delete.
  556.  
  557.  
  558. c!
  559. text
  560. .
  561.  
  562.      The variant toggles autoindent during the change.
  563.  
  564.  
  565. ( . , . )copy addr flags                abbr: co
  566.  
  567.      A  copy  of  the  specified lines is placed after addr,
  568.      which may be `0'.  The current line `.'  addresses  the
  569.      last  line of the copy.  The command t is a synonym for
  570.      copy.
  571.  
  572.  
  573. ( . , . )delete buffer count flags      abbr: d
  574.  
  575.      Removes the specified lines from the buffer.  The  line
  576.      after  the  last line deleted becomes the current line;
  577.      if the lines deleted were originally at  the  end,  the
  578.      new  last  line  becomes  the current line.  If a named
  579.      buffer is specified by giving a letter, then the speci-
  580.      fied  lines are saved in that buffer, or appended to it
  581.      if an upper case letter is used.
  582.  
  583.  
  584. edit file                               abbr: e
  585. ex file
  586.  
  587.      Used to begin an editing session on a  new  file.   The
  588.      editor  first  checks  to  see  if  the buffer has been
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. USD:16-10                                Ex Reference Manual
  599.  
  600.  
  601.      modified since the last write command was  issued.   If
  602.      it  has  been,  a  warning is issued and the command is
  603.      aborted.  The command otherwise deletes the entire con-
  604.      tents  of  the  editor buffer, makes the named file the
  605.      current file and prints the new filename.  After insur-
  606.      ing that this file is sensible- the  editor  reads  the
  607.      file into its buffer.
  608.  
  609.      If  the  read  of the file completes without error, the
  610.      number of lines and characters read is typed.  If there
  611.      were  any  non-ASCII  characters  in  the file they are
  612.      stripped of their non-ASCII high  bits,  and  any  null
  613.      characters in the file are discarded.  If none of these
  614.      errors occurred, the file is considered edited.  If the
  615.      last  line  of  the  input file is missing the trailing
  616.      newline character, it will be supplied and a  complaint
  617.      will  be  issued.  This command leaves the current line
  618.      `.' at the last line read.=
  619.  
  620.  
  621. e! file
  622.  
  623.      The variant form suppresses the complaint about modifi-
  624.      cations  having been made and not written from the edi-
  625.      tor buffer, thus discarding all changes which have been
  626.      made before editing the new file.
  627.  
  628.  
  629. e +n file
  630.  
  631.      Causes the editor to begin at line n rather than at the
  632.      last line; n may also be an editor  command  containing
  633.      no spaces, e.g.: ``+/pat''.
  634.  
  635.  
  636. file                                    abbr: f
  637.  
  638.      Prints  the  current  file  name,  whether  it has been
  639.      `[Modified]' since the last write command,  whether  it
  640.      is  read only, the current line, the number of lines in
  641.      the buffer, and the percentage of the way  through  the
  642.      buffer of the current line.*
  643. -----------
  644. -  I.e.,  that  it  is not a binary file such as a
  645. directory, a block or character special file other
  646. than  /dev/tty,  a  terminal,  or a binary or exe-
  647. cutable file (as indicated by the first word).
  648. = If executed from within open or visual, the cur-
  649. rent line is initially the first line of the file.
  650. *  In the rare case that the current file is `[Not
  651. edited]' this is noted also; in this case you have
  652. to use the form w! to write to the file, since the
  653. editor is not sure that a write will not destroy a
  654. file  unrelated  to  the  current  contents of the
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. Ex Reference Manual                                USD:16-11
  665.  
  666.  
  667. file file
  668.  
  669.      The current file name is changed to file which is  con-
  670.      sidered `[Not edited]'.
  671.  
  672.  
  673. ( 1 , $ ) global /pat/ cmds             abbr: g
  674.  
  675.      First  marks  each  line  among  those  specified which
  676.      matches the given regular expression.  Then  the  given
  677.      command list is executed with `.' initially set to each
  678.      marked line.
  679.  
  680.      The command list consists of the remaining commands  on
  681.      the  current  input  line  and may continue to multiple
  682.      lines by ending all but the last such line with a  `\'.
  683.      If  cmds  (and  possibly  the  trailing / delimiter) is
  684.      omitted, each line matching pat  is  printed.   Append,
  685.      insert,  and  change  commands and associated input are
  686.      permitted; the `.' terminating input may be omitted  if
  687.      it would be on the last line of the command list.  Open
  688.      and visual commands are permitted in the  command  list
  689.      and take input from the terminal.
  690.  
  691.      The  global command itself may not appear in cmds.  The
  692.      undo command is  also  not  permitted  there,  as  undo
  693.      instead  can  be used to reverse the entire global com-
  694.      mand.  The options autoprint and autoindent are  inhib-
  695.      ited  during  a  global,  (and  possibly the trailing /
  696.      delimiter) and the value of the report option  is  tem-
  697.      porarily  infinite,  in  deference  to a report for the
  698.      entire global.  Finally, the context mark `'''  is  set
  699.      to  the  value  of `.' before the global command begins
  700.      and is not changed during a global command, except per-
  701.      haps by an open or visual within the global.
  702.  
  703.  
  704. g! /pat/ cmds                           abbr: v
  705.  
  706.      The  variant  form of global runs cmds at each line not
  707.      matching pat.
  708.  
  709.  
  710. ( . )insert                             abbr: i
  711. text
  712. .
  713.  
  714.      Places the given text before the specified  line.   The
  715.      current  line  is left at the last line input; if there
  716.      were none input it is  left  at  the  line  before  the
  717.      addressed  line.  This command differs from append only
  718.      in the placement of text.
  719. -----------
  720. buffer.
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. USD:16-12                                Ex Reference Manual
  731.  
  732.  
  733. i!
  734. text
  735. .
  736.  
  737.      The variant toggles autoindent during the insert.
  738.  
  739.  
  740. ( . , .+1 ) join count flags            abbr: j
  741.  
  742.      Places  the  text  from  a  specified  range  of  lines
  743.      together  on one line.  White space is adjusted at each
  744.      junction to provide at least one blank  character,  two
  745.      if  there  was a `.' at the end of the line, or none if
  746.      the first following character is a `)'.   If  there  is
  747.      already  white  space  at the end of the line, then the
  748.      white space at the start of the next line will be  dis-
  749.      carded.
  750.  
  751.  
  752. j!
  753.  
  754.      The  variant  causes a simpler join with no white space
  755.      processing; the characters in the lines are simply con-
  756.      catenated.
  757.  
  758.  
  759. ( . ) k x
  760.  
  761.      The  k  command  is  a  synonym  for mark.  It does not
  762.      require a blank or tab before the following letter.
  763.  
  764.  
  765. ( . , . ) list count flags
  766.  
  767.      Prints the specified lines in a more  unambiguous  way:
  768.      tabs  are  printed  as `^I' and the end of each line is
  769.      marked with a trailing `$'.  The current line  is  left
  770.      at the last line printed.
  771.  
  772.  
  773. map lhs rhs
  774.  
  775.      The  map  command  is  used to define macros for use in
  776.      visual mode.  Lhs should be a single character, or  the
  777.      sequence  ``#n'',  for n a digit, referring to function
  778.      key n.  When this character or function key is typed in
  779.      visual mode, it will be as though the corresponding rhs
  780.      had been typed.  On terminals  without  function  keys,
  781.      you  can  type ``#n''.  See section 6.9 of the ``Intro-
  782.      duction to Display Editing with Vi'' for more  details.
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. Ex Reference Manual                                USD:16-13
  797.  
  798.  
  799. ( . ) mark x
  800.  
  801.      Gives  the  specified  line mark x, a single lower case
  802.      letter.  The x must be preceded by a blank  or  a  tab.
  803.      The addressing form `'x' then addresses this line.  The
  804.      current line is not affected by this command.
  805.  
  806.  
  807. ( . , . ) move addr                     abbr: m
  808.  
  809.      The move command repositions the specified lines to  be
  810.      after  addr.   The first of the moved lines becomes the
  811.      current line.
  812.  
  813.  
  814. next                                    abbr: n
  815.  
  816.      The next file from the command line  argument  list  is
  817.      edited.
  818.  
  819.  
  820. n!
  821.  
  822.      The variant suppresses warnings about the modifications
  823.      to the buffer not having been written  out,  discarding
  824.      (irretrievably) any changes which may have been made.
  825.  
  826.  
  827. n filelist
  828. n +command filelist
  829.  
  830.      The  specified  filelist  is expanded and the resulting
  831.      list replaces the current argument list; the first file
  832.      in  the  new  list is then edited.  If command is given
  833.      (it must contain no spaces), then it is executed  after
  834.      editing the first such file.
  835.  
  836.  
  837. ( . , . ) number count flags            abbr: # or nu
  838.  
  839.      Prints  each specified line preceded by its buffer line
  840.      number.  The current line is  left  at  the  last  line
  841.      printed.
  842.  
  843.  
  844. ( . ) open flags                        abbr: o
  845. ( . ) open /pat/ flags
  846.  
  847.      Enters  intraline  editing  open mode at each addressed
  848.      line.  If pat is given, then the cursor will be  placed
  849.      initially at the beginning of the string matched by the
  850.      pattern.  To exit this mode use Q.  See An Introduction
  851.      to Display Editing with Vi for more details.
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. USD:16-14                                Ex Reference Manual
  863.  
  864.  
  865. preserve
  866.  
  867.      The current editor buffer is saved as though the system
  868.      had just crashed.  This command  is  for  use  only  in
  869.      emergencies  when  a  write  command has resulted in an
  870.      error and you don't know how to save your work.   After
  871.      a preserve you should seek help.
  872.  
  873.  
  874. ( . , . )print count                    abbr: p or P
  875.  
  876.      Prints the specified lines with non-printing characters
  877.      printed as control characters `^x'; delete (octal  177)
  878.      is  represented  as  `^?'.  The current line is left at
  879.      the last line printed.
  880.  
  881.  
  882. ( . )put buffer                         abbr: pu
  883.  
  884.      Puts back previously deleted or yanked lines.  Normally
  885.      used  with  delete to effect movement of lines, or with
  886.      yank to effect duplication of lines.  If no  buffer  is
  887.      specified,  then  the  last  deleted  or yanked text is
  888.      restored.*   By  using  a  named  buffer,  text  may be
  889.      restored that was saved there at any previous time.
  890.  
  891.  
  892. quit                                    abbr: q
  893.  
  894.      Causes ex to terminate.  No automatic write of the edi-
  895.      tor  buffer to a file is performed.  However, ex issues
  896.      a warning message if the file  has  changed  since  the
  897.      last write command was issued, and does not quit.- Nor-
  898.      mally,  you  will  wish  to  save your changes, and you
  899.      should give a write command; if  you  wish  to  discard
  900.      them, use the q! command variant.
  901.  
  902.  
  903. q!
  904.  
  905.      Quits from the editor, discarding changes to the buffer
  906.      without complaint.
  907.  
  908.  
  909. ( . ) read file                         abbr: r
  910.  
  911.      Places a copy of the text of  the  given  file  in  the
  912.      editing buffer after the specified line.  If no file is
  913. -----------
  914. * But no modifying commands may intervene  between
  915. the  delete  or yank and the put, nor may lines be
  916. moved between files without using a named  buffer.
  917. -  Ex  will  also  issue a diagnostic if there are
  918. more files in the argument list.
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. Ex Reference Manual                                USD:16-15
  929.  
  930.  
  931.      given the current file name is used.  The current  file
  932.      name  is not changed unless there is none in which case
  933.      file  becomes  the  current  name.    The   sensibility
  934.      restrictions  for the edit command apply here also.  If
  935.      the file buffer is empty and there is no  current  name
  936.      then ex treats this as an edit command.
  937.  
  938.      Address  `0'  is  legal for this command and causes the
  939.      file to  be  read  at  the  beginning  of  the  buffer.
  940.      Statistics  are  given as for the edit command when the
  941.      read successfully terminates.  After a read the current
  942.      line is the last line read.=
  943.  
  944.  
  945. ( . ) read  !command
  946.  
  947.      Reads the output of the command command into the buffer
  948.      after  the  specified line.  This is not a variant form
  949.      of the command, rather  a  read  specifying  a  command
  950.      rather  than a filename; a blank or tab before the ! is
  951.      mandatory.
  952.  
  953.  
  954. recover file
  955.  
  956.      Recovers file from the system save area.  Used after  a
  957.      accidental hangup of the phone** or a system crash** or
  958.      preserve command.  Except when  you  use  preserve  you
  959.      will be notified by mail when a file is saved.
  960.  
  961.  
  962. rewind                                  abbr: rew
  963.  
  964.      The argument list is rewound, and the first file in the
  965.      list is edited.
  966.  
  967.  
  968. rew!
  969.  
  970.      Rewinds the argument list discarding any  changes  made
  971.      to the current buffer.
  972.  
  973.  
  974. set parameter
  975.  
  976.      With  no  arguments,  prints those options whose values
  977.      have been changed from their defaults;  with  parameter
  978.      all it prints all of the option values.
  979.  
  980. -----------
  981. =  Within  open and visual the current line is set
  982. to the first line read rather than the last.
  983. **  The  system  saves a copy of the file you were
  984. editing only if you have made changes to the file.
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. USD:16-16                                Ex Reference Manual
  995.  
  996.  
  997.      Giving  an  option  name  followed by a `?'  causes the
  998.      current value of that option to be printed.  The `?' is
  999.      unnecessary   unless  the  option  is  Boolean  valued.
  1000.      Boolean options are given values  either  by  the  form
  1001.      `set  option' to turn them on or `set nooption' to turn
  1002.      them off; string and numeric options are  assigned  via
  1003.      the form `set option=value'.
  1004.  
  1005.      More  than  one parameter may be given to set; they are
  1006.      interpreted left-to-right.
  1007.  
  1008.  
  1009. shell                                   abbr: sh
  1010.  
  1011.      A new shell is created.  When  it  terminates,  editing
  1012.      resumes.
  1013.  
  1014.  
  1015. source file                             abbr: so
  1016.  
  1017.      Reads  and  executes  commands from the specified file.
  1018.      Source commands may be nested.
  1019.  
  1020.  
  1021. ( . , . ) substitute /pat/repl/ options count flagsabbr: s
  1022.  
  1023.      On each specified line, the first instance  of  pattern
  1024.      pat  is  replaced  by replacement pattern repl.  If the
  1025.      global indicator option character `g' appears, then all
  1026.      instances  are  substituted;  if the confirm indication
  1027.      character `c' appears, then  before  each  substitution
  1028.      the  line to be substituted is typed with the string to
  1029.      be substituted marked with `^' characters.   By  typing
  1030.      an  `y' one can cause the substitution to be performed,
  1031.      any other input causes no change to take place.   After
  1032.      a  substitute the current line is the last line substi-
  1033.      tuted.
  1034.  
  1035.      Lines may be split by substituting new-line  characters
  1036.      into them.  The newline in repl must be escaped by pre-
  1037.      ceding it with a `\'.  Other  metacharacters  available
  1038.      in pat and repl are described below.
  1039.  
  1040.  
  1041. stop
  1042.  
  1043.      Suspends the editor, returning control to the top level
  1044.      shell.  If autowrite  is  set  and  there  are  unsaved
  1045.      changes,  a  write  is done first unless the form stop!
  1046.      is used.  This commands is only  available  where  sup-
  1047.      ported by the teletype driver and operating system.
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. Ex Reference Manual                                USD:16-17
  1061.  
  1062.  
  1063. ( . , . ) substitute options count flagsabbr: s
  1064.  
  1065.      If pat and repl are omitted, then the last substitution
  1066.      is repeated.  This is a synonym for the & command.
  1067.  
  1068.  
  1069. ( . , . ) t addr flags
  1070.  
  1071.      The t command is a synonym for copy.
  1072.  
  1073.  
  1074. ta tag
  1075.  
  1076.      The focus of editing switches to the location  of  tag,
  1077.      switching to a different line in the current file where
  1078.      it is defined, or if necessary to another file.=
  1079.  
  1080.      The  tags file is normally created by a program such as
  1081.      ctags, and consists of a number  of  lines  with  three
  1082.      fields  separated  by  blanks or tabs.  The first field
  1083.      gives the name of the tag, the second the name  of  the
  1084.      file  where  the  tag  resides,  and the third gives an
  1085.      addressing form which can be used by the editor to find
  1086.      the  tag; this field is usually a contextual scan using
  1087.      `/pat/' to be immune to  minor  changes  in  the  file.
  1088.      Such  scans are always performed as if nomagic was set.
  1089.  
  1090.      The tag names in the tags file must be sorted alphabet-
  1091. ically.
  1092.  
  1093.  
  1094. unabbreviate word                       abbr: una
  1095.  
  1096.      Delete word from the list of abbreviations.
  1097.  
  1098.  
  1099. undo                                    abbr: u
  1100.  
  1101.      Reverses  the  changes  made  in the buffer by the last
  1102.      buffer editing command.  Note that global commands  are
  1103.      considered a single command for the purpose of undo (as
  1104.      are open and visual.)  Also,  the  commands  write  and
  1105.      edit  which  interact  with  the  file system cannot be
  1106.      undone.  Undo is its own inverse.
  1107.  
  1108.      Undo always marks the previous  value  of  the  current
  1109.      line  `.'   as `'''.  After an undo the current line is
  1110.      the first line restored or the line  before  the  first
  1111.      line  deleted  if no lines were restored.  For commands
  1112. -----------
  1113. = If you have modified  the  current  file  before
  1114. giving  a tag command, you must write it out; giv-
  1115. ing another tag command, specifying  no  tag  will
  1116. reuse the previous tag.
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. USD:16-18                                Ex Reference Manual
  1127.  
  1128.  
  1129.      with more global effect such as global and  visual  the
  1130.      current  line  regains  it's pre-command value after an
  1131.      undo.
  1132.  
  1133.  
  1134. unmap lhs
  1135.  
  1136.      The macro  expansion  associated  by  map  for  lhs  is
  1137.      removed.
  1138.  
  1139.  
  1140. ( 1 , $ ) v /pat/ cmds
  1141.  
  1142.      A  synonym  for  the global command variant g!, running
  1143.      the specified cmds on each line which  does  not  match
  1144.      pat.
  1145.  
  1146.  
  1147. version                                 abbr: ve
  1148.  
  1149.      Prints the current version number of the editor as well
  1150.      as the date the editor was last changed.
  1151.  
  1152.  
  1153. ( . ) visual type count flags           abbr: vi
  1154.  
  1155.      Enters visual mode at  the  specified  line.   Type  is
  1156.      optional  and may be `-' , `^' or `.'  as in the z com-
  1157.      mand to specify the placement of the specified line  on
  1158.      the screen.  By default, if type is omitted, the speci-
  1159.      fied line is placed as the  first  on  the  screen.   A
  1160.      count  specifies an initial window size; the default is
  1161.      the value of the option window.  See  the  document  An
  1162.      Introduction  to  Display  Editing  with  Vi  for  more
  1163.      details.  To exit this mode, type Q.
  1164.  
  1165.  
  1166. visual file
  1167. visual +n file
  1168.  
  1169.      From visual mode, this command is the same as edit.
  1170.  
  1171.  
  1172. ( 1 , $ ) write file                    abbr: w
  1173.  
  1174.      Writes changes made back to file, printing  the  number
  1175.      of  lines  and  characters  written.   Normally file is
  1176.      omitted and the text goes back where it came from.   If
  1177.      a  file is specified, then text will be written to that
  1178.      file.*  If the file does not exist it is created.   The
  1179. -----------
  1180. * The editor writes to a file only if  it  is  the
  1181. current  file  and is edited, if the file does not
  1182. exist, or if the  file  is  actually  a  teletype,
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. Ex Reference Manual                                USD:16-19
  1193.  
  1194.  
  1195.      current  file  name is changed only if there is no cur-
  1196.      rent file name; the current line is never changed.
  1197.  
  1198.      If an error occurs while writing the current and edited
  1199.      file,  the  editor  considers  that there has been ``No
  1200.      write since last change'' even if the  buffer  had  not
  1201.      previously been modified.
  1202.  
  1203.  
  1204. ( 1 , $ ) write>> file                  abbr: w>>
  1205.  
  1206.      Writes  the  buffer  contents at the end of an existing
  1207.      file.
  1208.  
  1209.  
  1210.  
  1211. w! name
  1212.  
  1213.      Overrides the checking of the normal write command, and
  1214.      will write to any file which the system permits.
  1215.  
  1216.  
  1217. ( 1 , $ ) w  !command
  1218.  
  1219.      Writes the specified lines into command.  Note the dif-
  1220.      ference between w!  which  overrides  checks  and  w  !
  1221.      which writes to a command.
  1222.  
  1223.  
  1224. wq name
  1225.  
  1226.      Like a write and then a quit command.
  1227.  
  1228.  
  1229. wq! name
  1230.  
  1231.      The  variant  overrides  checking on the sensibility of
  1232.      the write command, as w! does.
  1233.  
  1234.  
  1235. xit name
  1236.  
  1237.      If any changes have been made and not  written,  writes
  1238.      the buffer out.  Then, in any case, quits.
  1239.  
  1240.  
  1241. ( . , . )yank buffer count              abbr: ya
  1242.  
  1243.      Places  the  specified  lines  in the named buffer, for
  1244.      later retrieval via put.  If no buffer name  is  speci-
  1245.      fied,  the  lines  go to a more volatile place; see the
  1246. -----------
  1247. /dev/tty, /dev/null.  Otherwise, you must give the
  1248. variant form w! to force the write.
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. USD:16-20                                Ex Reference Manual
  1259.  
  1260.  
  1261.      put command description.
  1262.  
  1263.  
  1264. ( .+1 ) z count
  1265.  
  1266.      Print the next count lines, default window.
  1267.  
  1268.  
  1269. ( . ) z type count
  1270.  
  1271.      Prints a window of text with the specified line at  the
  1272.      top.   If type is `-' the line is placed at the bottom;
  1273.      a `.' causes the line to be placed in the  center.*   A
  1274.      count  gives the number of lines to be displayed rather
  1275.      than double the number specified by the scroll  option.
  1276.      On  a  CRT  the screen is cleared before display begins
  1277.      unless a count which is less than the  screen  size  is
  1278.      given.   The  current  line  is  left  at the last line
  1279.      printed.
  1280.  
  1281.  
  1282. ! command
  1283.  
  1284.      The remainder of the line after the  `!'  character  is
  1285.      sent  to  a  shell  to be executed.  Within the text of
  1286.      command the characters `%' and `#' are expanded  as  in
  1287.      filenames  and  the  character `!' is replaced with the
  1288.      text of the previous  command.   Thus,  in  particular,
  1289.      `!!'  repeats  the last such shell escape.  If any such
  1290.      expansion is  performed,  the  expanded  line  will  be
  1291.      echoed.  The current line is unchanged by this command.
  1292.  
  1293.      If there has been ``[No write]'' of the buffer contents
  1294.      since  the  last  change  to the editing buffer, then a
  1295.      diagnostic will be printed before the command  is  exe-
  1296.      cuted  as  a warning.  A single `!' is printed when the
  1297.      command completes.
  1298.  
  1299.  
  1300. ( addr , addr ) ! command
  1301.  
  1302.      Takes the specified address range and  supplies  it  as
  1303.      standard  input  to  command; the resulting output then
  1304.      replaces the input lines.
  1305.  
  1306.  
  1307. -----------
  1308. * Forms `z=' and `z^' also exist; `z=' places  the
  1309. current  line  in  the  center,  surrounds it with
  1310. lines of `-' characters  and  leaves  the  current
  1311. line  at this line.  The form `z^' prints the win-
  1312. dow before `z-' would.  The  characters  `+',  `^'
  1313. and `-' may be repeated for cumulative effect.  On
  1314. some v2 editors, no type may be given.
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. Ex Reference Manual                                USD:16-21
  1325.  
  1326.  
  1327. ( $ ) =
  1328.  
  1329.      Prints the line number of the addressed line.  The cur-
  1330.      rent line is unchanged.
  1331.  
  1332.  
  1333. ( . , . ) > count flags
  1334. ( . , . ) < count flags
  1335.  
  1336.      Perform  intelligent shifting on the specified lines; <
  1337.      shifts left and > shift right.  The quantity  of  shift
  1338.      is  determined by the shiftwidth option and the repeti-
  1339.      tion of the specification character.  Only white  space
  1340.      (blanks  and  tabs) is shifted; no non-white characters
  1341.      are  discarded  in  a  left-shift.   The  current  line
  1342.      becomes  the  last line which changed due to the shift-
  1343.      ing.
  1344.  
  1345.  
  1346. ^D
  1347.  
  1348.      An end-of-file from a terminal  input  scrolls  through
  1349.      the  file.  The scroll option specifies the size of the
  1350.      scroll, normally a half screen of text.
  1351.  
  1352.  
  1353. ( .+1 , .+1 )
  1354. ( .+1 , .+1 ) |
  1355.  
  1356.      An address alone  causes  the  addressed  lines  to  be
  1357.      printed.   A  blank  line  prints  the next line in the
  1358.      file.
  1359.  
  1360.  
  1361. ( . , . ) & options count flags
  1362.  
  1363.      Repeats the previous substitute command.
  1364.  
  1365.  
  1366. ( . , . ) ~ options count flags
  1367.  
  1368.      Replaces the previous regular expression with the  pre-
  1369.      vious replacement pattern from a substitution.
  1370.  
  1371. 8.  Regular expressions and substitute replacement patterns
  1372.  
  1373. 8.1.  Regular expressions
  1374.  
  1375.      A  regular  expression  specifies  a  set of strings of
  1376. characters.  A member of this set of strings is said  to  be
  1377. matched  by the regular expression.  Ex remembers two previ-
  1378. ous regular expressions:  the  previous  regular  expression
  1379. used  in  a  substitute  command  and  the  previous regular
  1380. expression used  elsewhere  (referred  to  as  the  previous
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. USD:16-22                                Ex Reference Manual
  1391.  
  1392.  
  1393. scanning  regular expression.)  The previous regular expres-
  1394. sion can always be referred to by a null re,  e.g.  `//'  or
  1395. `??'.
  1396.  
  1397. 8.2.  Magic and nomagic
  1398.  
  1399.      The  regular  expressions allowed by ex are constructed
  1400. in one of two ways depending on the  setting  of  the  magic
  1401. option.   The ex and vi default setting of magic gives quick
  1402. access to a powerful set of regular  expression  metacharac-
  1403. ters.   The  disadvantage  of  magic  is  that the user must
  1404. remember that these metacharacters  are  magic  and  precede
  1405. them  with  the  character  `\'  to use them as ``ordinary''
  1406. characters.  With nomagic, the  default  for  edit,  regular
  1407. expressions are much simpler, there being only two metachar-
  1408. acters.  The power of  the  other  metacharacters  is  still
  1409. available  by  preceding the (now) ordinary character with a
  1410. `\'.  Note that `\' is thus always a metacharacter.
  1411.  
  1412.      The remainder of the discussion of regular  expressions
  1413. assumes that that the setting of this option is magic.-
  1414.  
  1415. 8.3.  Basic regular expression summary
  1416.  
  1417.      The following basic constructs are  used  to  construct
  1418. magic mode regular expressions.
  1419.  
  1420. char           An  ordinary  character  matches itself.  The
  1421.                characters `^' at the beginning  of  a  line,
  1422.                `$'  at the end of line, `*' as any character
  1423.                other than the first, `.', `\', `[', and  `~'
  1424.                are  not  ordinary  characters  and  must  be
  1425.                escaped (preceded) by `\' to  be  treated  as
  1426.                such.
  1427.  
  1428. ^              At  the  beginning  of  a  pattern forces the
  1429.                match to succeed only at the beginning  of  a
  1430.                line.
  1431.  
  1432. $              At the end of a regular expression forces the
  1433.                match to succeed only at the end of the line.
  1434.  
  1435. .              Matches  any single character except the new-
  1436.                line character.
  1437.  
  1438. -----------
  1439. - To discern what is true with nomagic it suffices
  1440. to remember that the only  special  characters  in
  1441. this  case will be `^' at the beginning of a regu-
  1442. lar expression,  `$'  at  the  end  of  a  regular
  1443. expression,  and `\'.  With nomagic the characters
  1444. `~' and  `&'  also  lose  their  special  meanings
  1445. related  to  the  replacement pattern of a substi-
  1446. tute.
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. Ex Reference Manual                                USD:16-23
  1457.  
  1458.  
  1459. \<             Forces the match to occur only at the  begin-
  1460.                ning  of a ``variable'' or ``word''; that is,
  1461.                either at the beginning of a  line,  or  just
  1462.                before  a  letter,  digit,  or  underline and
  1463.                after a character not one of these.
  1464.  
  1465. \>             Similar to `\<', but matching the  end  of  a
  1466.                ``variable'' or ``word'', i.e. either the end
  1467.                of the line or before character which is nei-
  1468.                ther a letter, nor a digit, nor the underline
  1469.                character.
  1470.  
  1471. [string]       Matches any (single) character in  the  class
  1472.                defined by string.  Most characters in string
  1473.                define themselves.  A pair of characters sep-
  1474.                arated  by  `-'  in string defines the set of
  1475.                characters collating  between  the  specified
  1476.                lower  and  upper  bounds,  thus `[a-z]' as a
  1477.                regular  expression  matches   any   (single)
  1478.                lower-case letter.  If the first character of
  1479.                string is an `^' then the  construct  matches
  1480.                those  characters  which  it  otherwise would
  1481.                not; thus `[^a-z]'  matches  anything  but  a
  1482.                lower-case  letter (and of course a newline).
  1483.                To place any of the characters `^',  `[',  or
  1484.                `-'  in  string  you  must escape them with a
  1485.                preceding `\'.
  1486.  
  1487. 8.4.  Combining regular expression primitives
  1488.  
  1489.      The concatenation of two  regular  expressions  matches
  1490. the  leftmost  and  then longest string which can be divided
  1491. with the first piece matching the first  regular  expression
  1492. and  the second piece matching the second.  Any of the (sin-
  1493. gle character matching) regular expressions mentioned  above
  1494. may  be  followed  by  the  character  `*' to form a regular
  1495. expression which matches any number of adjacent  occurrences
  1496. (including  0)  of characters matched by the regular expres-
  1497. sion it follows.
  1498.  
  1499.      The character `~' may be used in a regular  expression,
  1500. and  matches  the text which defined the replacement part of
  1501. the last substitute command.  A regular  expression  may  be
  1502. enclosed  between  the  sequences  `\('  and  `\)' with side
  1503. effects in the substitute replacement patterns.
  1504.  
  1505. 8.5.  Substitute replacement patterns
  1506.  
  1507.      The basic metacharacters for  the  replacement  pattern
  1508. are  `&'  and  `~';  these  are  given as `\&' and `\~' when
  1509. nomagic is set.  Each instance of `&'  is  replaced  by  the
  1510. characters   which  the  regular  expression  matched.   The
  1511. metacharacter `~' stands, in the  replacement  pattern,  for
  1512. the defining text of the previous replacement pattern.
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. USD:16-24                                Ex Reference Manual
  1523.  
  1524.  
  1525.      Other metasequences possible in the replacement pattern
  1526. are always introduced by the escaping  character  `\'.   The
  1527. sequence  `\n'  is  replaced by the text matched by the n-th
  1528. regular subexpression enclosed between `\(' and  `\)'.-  The
  1529. sequences  `\u'  and  `\l'  cause  the immediately following
  1530. character in the replacement to be converted  to  upper-  or
  1531. lower-case  respectively if this character is a letter.  The
  1532. sequences `\U' and `\L'  turn  such  conversion  on,  either
  1533. until  `\E'  or `\e' is encountered, or until the end of the
  1534. replacement pattern.
  1535.  
  1536. 9.  Option descriptions
  1537.  
  1538.  
  1539.  
  1540. autoindent, ai                default: noai
  1541.  
  1542.      Can be used to ease the preparation of structured  pro-
  1543.      gram  text.  At the beginning of each append, change or
  1544.      insert command or when a new line is opened or  created
  1545.      by  an  append, change, insert, or substitute operation
  1546.      within open or visual mode, ex looks at the line  being
  1547.      appended  after,  the  first  line  changed or the line
  1548.      inserted before and  calculates  the  amount  of  white
  1549.      space  at  the  start  of the line.  It then aligns the
  1550.      cursor at the level of indentation so determined.
  1551.  
  1552.      If the user then types lines of text in, they will con-
  1553.      tinue to be justified at the displayed indenting level.
  1554.      If more white space is typed  at  the  beginning  of  a
  1555.      line,  the  following  line will start aligned with the
  1556.      first non-white character of  the  previous  line.   To
  1557.      back  the  cursor  up to the preceding tab stop one can
  1558.      hit ^D.  The tab stops going backwards are  defined  at
  1559.      multiples   of   the  shiftwidth  option.   You  cannot
  1560.      backspace over the indent, except by sending an end-of-
  1561.      file with a ^D.
  1562.  
  1563.      Specially  processed  in  this  mode  is a line with no
  1564.      characters added to it, which turns into  a  completely
  1565.      blank line (the white space provided for the autoindent
  1566.      is discarded.)  Also specially processed in  this  mode
  1567.      are  lines  beginning  with an `^' and immediately fol-
  1568.      lowed by a ^D.  This causes the  input  to  be  reposi-
  1569.      tioned  at the beginning of the line, but retaining the
  1570.      previous indent for the next line.   Similarly,  a  `0'
  1571.      followed by a ^D repositions at the beginning but with-
  1572.      out retaining the previous indent.
  1573.  
  1574.  
  1575. -----------
  1576. - When nested,  parenthesized  subexpressions  are
  1577. present,  n  is determined by counting occurrences
  1578. of `\(' starting from the left.
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. Ex Reference Manual                                USD:16-25
  1589.  
  1590.  
  1591.      Autoindent doesn't happen in global  commands  or  when
  1592.      the input is not a terminal.
  1593.  
  1594.  
  1595. autoprint, ap                 default: ap
  1596.  
  1597.      Causes  the  current  line  to  be  printed  after each
  1598.      delete, copy, join, move, substitute, t, undo or  shift
  1599.      command.   This  has  the  same  effect  as supplying a
  1600.      trailing `p' to each such command.  Autoprint  is  sup-
  1601.      pressed  in  globals,  and  only applies to the last of
  1602.      many commands on a line.
  1603.  
  1604.  
  1605. autowrite, aw                 default: noaw
  1606.  
  1607.      Causes the contents of the buffer to be written to  the
  1608.      current  file  if you have modified it and give a next,
  1609.      rewind, stop, tag, or  !   command,  or  a  ^^  (switch
  1610.      files)  or ^] (tag goto) command in visual.  Note, that
  1611.      the edit and ex commands do  not  autowrite.   In  each
  1612.      case,  there  is  an  equivalent  way of switching when
  1613.      autowrite is set to avoid the autowrite (edit for next,
  1614.      rewind!   for  .I  rewind  , stop!  for stop, tag!  for
  1615.      tag, shell for !, and :e #  and  a  :ta!  command  from
  1616.      within visual).
  1617.  
  1618.  
  1619. beautify, bf                  default: nobeautify
  1620.  
  1621.      Causes  all  control characters except tab, newline and
  1622.      form-feed to be discarded from the input.  A  complaint
  1623.      is  registered  the first time a backspace character is
  1624.      discarded.  Beautify does not apply to command input.
  1625.  
  1626.  
  1627. directory, dir                default: dir=/tmp
  1628.  
  1629.      Specifies the directory in which ex places  its  buffer
  1630.      file.  If this directory in not writable, then the edi-
  1631.      tor will exit abruptly when it fails to be able to cre-
  1632.      ate its buffer there.
  1633.  
  1634.  
  1635. edcompatible                  default: noedcompatible
  1636.  
  1637.      Causes  the  presence of absence of g and c suffixes on
  1638.      substitute commands to be remembered, and to be toggled
  1639.      by repeating the suffices.  The suffix r makes the sub-
  1640.      stitution be as in the ~ command, instead of like &.
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. USD:16-26                                Ex Reference Manual
  1655.  
  1656.  
  1657. errorbells, eb                default: noeb
  1658.  
  1659.      Error  messages  are  preceded by a bell.*  If possible
  1660.      the editor always places the error message in a  stand-
  1661.      out  mode  of  the  terminal  (such  as  inverse video)
  1662.      instead of ringing the bell.
  1663.  
  1664.  
  1665. hardtabs, ht                  default: ht=8
  1666.  
  1667.      Gives the boundaries on which  terminal  hardware  tabs
  1668.      are set (or on which the system expands tabs).
  1669.  
  1670.  
  1671. ignorecase, ic                default: noic
  1672.  
  1673.      All  upper  case  characters  in the text are mapped to
  1674.      lower case in regular expression  matching.   In  addi-
  1675.      tion,  all upper case characters in regular expressions
  1676.      are mapped to lower  case  except  in  character  class
  1677.      specifications.
  1678.  
  1679.  
  1680. lisp                          default: nolisp
  1681.  
  1682.      Autoindent indents appropriately for lisp code, and the
  1683.      ( ) { } [[ and ]] commands in open and visual are modi-
  1684.      fied to have meaning for lisp.
  1685.  
  1686.  
  1687. list                          default: nolist
  1688.  
  1689.      All  printed  lines  will be displayed (more) unambigu-
  1690.      ously, showing tabs and end-of-lines  as  in  the  list
  1691.      command.
  1692.  
  1693.  
  1694. magic                         default: magic for ex and vi-
  1695.  
  1696.      If  nomagic  is  set,  the number of regular expression
  1697.      metacharacters is greatly reduced, with  only  `^'  and
  1698.      `$'  having special effects.  In addition the metachar-
  1699.      acters `~' and  `&'  of  the  replacement  pattern  are
  1700.      treated as normal characters.  All the normal metachar-
  1701.      acters may be made magic when nomagic is set by preced-
  1702.      ing them with a `\'.
  1703.  
  1704.  
  1705.  
  1706.  
  1707. -----------
  1708. * Bell ringing in open and visual on errors is not
  1709. suppressed by setting noeb.
  1710. - Nomagic for edit.
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. Ex Reference Manual                                USD:16-27
  1721.  
  1722.  
  1723. mesg                          default: mesg
  1724.  
  1725.      Causes  write permission to be turned off to the termi-
  1726.      nal while you are in visual mode, if nomesg is set.
  1727.  
  1728.  
  1729. modeline                      default: nomodeline
  1730.  
  1731.      If modeline is set, then the first 5 lines and the last
  1732.      five  lines  of the file will be checked for ex command
  1733.      lines and the comands issued.  To be  recognized  as  a
  1734.      command  line, the line must have the string ex: or vi:
  1735.      preceeded by a tab or a space.  This string may be any-
  1736.      where  in  the  line and anything after the : is inter-
  1737.      peted as editor commands.  This option defaults to  off
  1738.      because of unexpected behavior when editting files such
  1739.      as /etc/passwd.
  1740.  
  1741.  
  1742. number, nu                    default: nonumber
  1743.  
  1744.      Causes all output lines to be printed with  their  line
  1745.      numbers.   In addition each input line will be prompted
  1746.      for by supplying the line number it will have.
  1747.  
  1748.  
  1749. open                          default: open
  1750.  
  1751.      If noopen, the commands open and visual are not permit-
  1752.      ted.  This is set for edit to prevent confusion result-
  1753.      ing from accidental entry to open or visual mode.
  1754.  
  1755.  
  1756. optimize, opt                 default: optimize
  1757.  
  1758.      Throughput of text is expedited by setting the terminal
  1759.      to not do automatic carriage returns when printing more
  1760.      than one (logical) line  of  output,  greatly  speeding
  1761.      output  on  terminals  without addressable cursors when
  1762.      text with leading white space is printed.
  1763.  
  1764.  
  1765. paragraphs, para              default: para=IPLPPPQPP LIbp
  1766.  
  1767.      Specifies the paragraphs for the { and } operations  in
  1768.      open  and  visual.   The  pairs  of  characters  in the
  1769.      option's value are the names of the macros which  start
  1770.      paragraphs.
  1771.  
  1772.  
  1773. prompt                        default: prompt
  1774.  
  1775.      Command mode input is prompted for with a `:'.
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. USD:16-28                                Ex Reference Manual
  1787.  
  1788.  
  1789. redraw                        default: noredraw
  1790.  
  1791.      The  editor  simulates (using great amounts of output),
  1792.      an intelligent terminal on a dumb terminal (e.g. during
  1793.      insertions in visual the characters to the right of the
  1794.      cursor position are refreshed as each  input  character
  1795.      is typed.)  Useful only at very high speed.
  1796.  
  1797.  
  1798. remap                         default: remap
  1799.  
  1800.      If  on,  macros  are  repeatedly  tried  until they are
  1801.      unchanged.  For example, if o is mapped to O, and O  is
  1802.      mapped to I, then if remap is set, o will map to I, but
  1803.      if noremap is set, it will map to O.
  1804.  
  1805.  
  1806. report                        default: report=5-
  1807.  
  1808.      Specifies a threshold for feedback from commands.   Any
  1809.      command  which  modifies more than the specified number
  1810.      of lines will provide feedback as to the scope  of  its
  1811.      changes.   For commands such as global, open, undo, and
  1812.      visual which have potentially more far reaching  scope,
  1813.      the  net change in the number of lines in the buffer is
  1814.      presented at the end of the command,  subject  to  this
  1815.      same threshold.  Thus notification is suppressed during
  1816.      a global command on the individual commands  performed.
  1817.  
  1818.  
  1819. scroll                        default: scroll=1/2 window
  1820.  
  1821.      Determines the number of logical lines scrolled when an
  1822.      end-of-file is received from a terminal input  in  com-
  1823.      mand mode, and the number of lines printed by a command
  1824.      mode z command (double the value of scroll).
  1825.  
  1826.  
  1827. sections                      default: sections=SHNHH HU
  1828.  
  1829.      Specifies the section macros for the [[ and  ]]  opera-
  1830.      tions  in  open and visual.  The pairs of characters in
  1831.      the options's value are the names of the  macros  which
  1832.      start paragraphs.
  1833.  
  1834.  
  1835. shell, sh                     default: sh=/bin/sh
  1836.  
  1837.      Gives  the  path name of the shell forked for the shell
  1838.      escape command `!', and  by  the  shell  command.   The
  1839.      default is taken from SHELL in the environment, if pre-
  1840.      sent.
  1841. -----------
  1842. - 2 for edit.
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. Ex Reference Manual                                USD:16-29
  1853.  
  1854.  
  1855. shiftwidth, sw                default: sw=8
  1856.  
  1857.      Gives the width a software tab stop,  used  in  reverse
  1858.      tabbing  with  ^D when using autoindent to append text,
  1859.      and by the shift commands.
  1860.  
  1861.  
  1862. showmatch, sm                 default: nosm
  1863.  
  1864.      In open and visual mode, when a ) or } is  typed,  move
  1865.      the  cursor  to  the  matching ( or { for one second if
  1866.      this matching character is on  the  screen.   Extremely
  1867.      useful with lisp.
  1868.  
  1869.  
  1870. slowopen, slow                terminal dependent
  1871.  
  1872.      Affects  the  display  algorithm  used  in visual mode,
  1873.      holding off display updating during input of  new  text
  1874.      to  improve throughput when the terminal in use is both
  1875.      slow and unintelligent.  See An Introduction to Display
  1876.      Editing with Vi for more details.
  1877.  
  1878.  
  1879. tabstop, ts                   default: ts=8
  1880.  
  1881.      The editor expands tabs in the input file to be on tab-
  1882.      stop boundaries for the purposes of display.
  1883.  
  1884.  
  1885. taglength, tl                 default: tl=0
  1886.  
  1887.      Tags are not significant beyond this  many  characters.
  1888.      A value of zero (the default) means that all characters
  1889.      are significant.
  1890.  
  1891.  
  1892. tags                          default:             tags=tags
  1893. /usr/lib/tags
  1894.  
  1895.      A  path  of  files  to be used as tag files for the tag
  1896.      command.  A requested tag is searched for in the speci-
  1897.      fied  files,  sequentially.   By  default, files called
  1898.      tags are searched for in the current directory  and  in
  1899.      /usr/lib (a master file for the entire system).
  1900.  
  1901.  
  1902. term                          from environment TERM
  1903.  
  1904.      The terminal type of the output device.
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. USD:16-30                                Ex Reference Manual
  1919.  
  1920.  
  1921. terse                         default: noterse
  1922.  
  1923.      Shorter  error diagnostics are produced for the experi-
  1924.      enced user.
  1925.  
  1926.  
  1927. warn                          default: warn
  1928.  
  1929.      Warn if there has been `[No write since  last  change]'
  1930.      before a `!'  command escape.
  1931.  
  1932.  
  1933. window                        default:  window=speed  depen-
  1934. dent
  1935.  
  1936.      The number of lines in a text window in the visual com-
  1937.      mand.   The  default  is  8 at slow speeds (600 baud or
  1938.      less), 16 at medium speed (1200  baud),  and  the  full
  1939.      screen (minus one line) at higher speeds.
  1940.  
  1941.  
  1942. w300, w1200 w9600
  1943.  
  1944.      These  are  not true options but set window only if the
  1945.      speed is slow (300), medium  (1200),  or  high  (9600),
  1946.      respectively.  They are suitable for an EXINIT and make
  1947.      it easy to change the 8/16/full screen rule.
  1948.  
  1949.  
  1950. wrapscan, ws                  default: ws
  1951.  
  1952.      Searches using the regular  expressions  in  addressing
  1953.      will wrap around past the end of the file.
  1954.  
  1955.  
  1956. wrapmargin, wm                default: wm=0
  1957.  
  1958.      Defines  a margin for automatic wrapover of text during
  1959.      input in open and visual modes.  See An Introduction to
  1960.      Text Editing with Vi for details.
  1961.  
  1962.  
  1963. writeany, wa                  default: nowa
  1964.  
  1965.      Inhibit the checks normally made before write commands,
  1966.      allowing a write to any file which the  system  protec-
  1967.      tion mechanism will allow.
  1968.  
  1969. 10.  Limitations
  1970.  
  1971.      Editor  limits that the user is likely to encounter are
  1972. as follows: 1024 characters per  line,  256  characters  per
  1973. global command list, 128 characters per file name, 128 char-
  1974. acters in the previous inserted and deleted text in open  or
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. Ex Reference Manual                                USD:16-31
  1985.  
  1986.  
  1987. visual, 100 characters in a shell escape command, 63 charac-
  1988. ters in a string valued option, and 30 characters in  a  tag
  1989. name,  and  a  limit of 250000 lines in the file is silently
  1990. enforced.
  1991.  
  1992.      The visual implementation limits the number  of  macros
  1993. defined  with  map to 32, and the total number of characters
  1994. in macros to be less than 512.
  1995.  
  1996.  
  1997. Acknowledgments.  Chuck Haley  contributed  greatly  to  the
  1998. early  development  of  ex.   Bruce  Englar  encouraged  the
  1999. redesign which led to ex version 1.  Bill Joy wrote versions
  2000. 1  and 2.0 through 2.7, and created the framework that users
  2001. see in the present editor.  Mark  Horton  added  macros  and
  2002. other features and made the editor work on a large number of
  2003. terminals and Unix systems.
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.