home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / riscbsd / datafile / usd / 16_ex / ex_summary < prev   
Encoding:
Text File  |  1996-10-12  |  13.1 KB  |  529 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Ex/Edit Command Summary (Version 2.0)
  8.    Ex  and  edit  are text edi-     visual modes, discussed below.)
  9. tors,  used  for  creating  and     In  command  mode,  the  editor
  10. modifying  files of text on the     issues  a  colon  prompt (:) to
  11. UNIX computer system.  Edit  is     show that it is ready to accept
  12. a  variant  of ex with features     and execute a command.  In text
  13. designed to make it  less  com-     input mode, on the other  hand,
  14. plicated  to learn and use.  In     there is no prompt and the edi-
  15. terms  of  command  syntax  and     tor merely accepts text  to  be
  16. effect  the  editors are essen-     added   to  the  buffer.   Text
  17. tially identical, and this com-     input mode is initiated by  the
  18. mand summary applies to both.       commands  append,  insert,  and
  19.    The  summary  is  meant as a     change, and  is  terminated  by
  20. quick   reference   for   users     typing  a  period  as the first
  21. already acquainted with edit or     and only character on a line.
  22. ex.  Fuller explanations of the     Line Numbers and Command Syntax
  23. editors  are  available  in the        The  editor  keeps  track of
  24. documents Edit: A  Tutorial  (a     lines of text in the buffer  by
  25. self-teaching introduction) and     numbering   them  consecutively
  26. the Ex  Reference  Manual  (the     starting with 1 and renumbering
  27. comprehensive  reference source     as  lines are added or deleted.
  28. for both edit and ex).  Both of     At any given time the editor is
  29. these writeups are available in     positioned   at  one  of  these
  30. the Computing Services Library.     lines; this position is  called
  31.    In   the  examples  included     the  current  line.  Generally,
  32. with the summary, commands  and     commands that change  the  con-
  33. text  entered  by  the user are     tents  of  the buffer print the
  34. printed in boldface to  distin-     new current line at the end  of
  35. guish   them   from   responses     their execution.
  36. printed by the computer.               Most  commands  can  be pre-
  37. The Editor Buffer                   ceded by one or two line-number
  38.    In  order  to  perform   its     addresses  which  indicate  the
  39. tasks  the  editor sets aside a     lines to be affected.   If  one
  40. temporary work space, called  a     number  is  given  the  command
  41. buffer,   separate   from   the     operates on that line only;  if
  42. user's permanent file.   Before     two,  on  an inclusive range of
  43. starting to work on an existing     lines.  Commands that can  take
  44. file the editor makes a copy of     line-number    prefixes    also
  45. it  in  the buffer, leaving the     assume default prefixes if none
  46. original untouched.  All  edit-     are given.  The default assumed
  47. ing  changes  are  made  to the     by each command is designed  to
  48. buffer copy, which must then be     make  it  convenient  to use in
  49. written  back  to the permanent     many  instances   without   any
  50. file in order to update the old     line-number  prefix.   For  the
  51. version.  The buffer disappears     most part, a command used with-
  52. at the end of the editing  ses-     out  a  prefix  operates on the
  53. sion.                               current line, though exceptions
  54. Editing: Command and Text Input     to  this  rule should be noted.
  55. Modes                               The print  command  by  itself,
  56.    During  an  editing  session     for  instance, causes one line,
  57. there  are  two  usual modes of     the current line, to be printed
  58. operation:  command  mode   and     at the terminal.
  59. text  input mode.  (This disre-        The summary shows the number
  60. gards, for the moment, open and     of line addresses that  can  be
  61.  
  62.  
  63.  
  64. Computing Services, U.C. Berkeley                     April 3, 1979
  65.  
  66.  
  67.  
  68.  
  69.  
  70. prefixed  to  each  command  as
  71. well as the defaults assumed if
  72. they are omitted.  For example,
  73. (.,.)  means that up to 2 line-
  74. numbers  may be given, and that
  75. if none is  given  the  command
  76. operates  on  the current line.
  77. (In the  address  prefix  nota-
  78. tion, ``.'' stands for the cur-
  79. rent line and ``$'' stands  for
  80. the  last  line of the buffer.)
  81. If no such notation appears, no
  82. line-number prefix may be used.
  83.    Some commands take  trailing
  84. information;   only   the  more
  85. important instances of this are
  86. mentioned in the summary.
  87. Open and Visual Modes
  88.    Besides   command  and  text
  89. input modes, ex and  edit  pro-
  90. vide   on  some  CRT  terminals
  91. other modes  of  editing,  open
  92. and visual.  In these modes the
  93. cursor can be moved to individ-
  94. ual  words  or  characters in a
  95. line.  The commands then  given
  96. are  very  different  from  the
  97. standard editor commands;  most
  98. do  not  appear  on  the screen
  99. when typed.  An Introduction to
  100. Display  Editing  with  Vi pro-
  101. vides a full discussion.
  102. Special Characters
  103.    Some characters take on spe-
  104. cial meanings when used in con-
  105. text searches and  in  patterns
  106. given  to  the  substitute com-
  107. mand.   For  edit,  these   are
  108. ``^''  and  ``$'',  meaning the
  109. beginning and end  of  a  line,
  110. respectively.   Ex has the fol-
  111. lowing additional special char-
  112. acters:
  113. .     &     *     [     ]     ~
  114. To use one of the special char-
  115. acters as  its  simple  graphic
  116. representation rather than with
  117. its special meaning, precede it
  118. by  a backslash (\).  The back-
  119. slash  always  has  a   special
  120. meaning.
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. Computing Services, U.C. Berkeley                     April 3, 1979
  131.  
  132.  
  133.  
  134.  
  135.  
  136. cp10  cp10  cp10  cp10 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
  137. Name Abbr Description    Examples
  138.  
  139.  
  140. (.)append a    T{ Begins text  input  mode,  adding  lines  to  the
  141. buffer after the line specified. Appending continues until ``.'' is
  142. typed alone at the beginning of a new line, followed by a  carriage
  143. return. 0a places lines at the beginning of the buffer.  T}   T{
  144. :a
  145. Three lines of text
  146. are added to the buffer
  147. after the current line.
  148. .
  149. :
  150. T}
  151.  
  152. (.,.)change    c    T{ Deletes indicated line(s) and initiates text
  153. input mode to replace them with new text which follows.   New  text
  154. is terminated the same way as with append.  T}   T{
  155. :5,6c
  156. Lines 5 and 6 are
  157. deleted and replaced by
  158. these three lines.
  159. .
  160. :
  161. T}
  162.  
  163. (.,.)copy  addr co   T{  Places a copy of the specified lines after
  164. the line indicated by addr.  The example places a copy of  lines  8
  165. through 12, inclusive, after line 25.  T}   T{
  166. :8,12co 25
  167. Last line copied is printed
  168. :
  169. T}
  170.  
  171. (.,.)delete    d    T{ Removes lines from the buffer and prints the
  172. current line after the deletion.  T}   T{
  173. :13,15d
  174. New current line is printed
  175. :
  176. T}
  177.  
  178.  
  179. ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).  T{ edit file
  180. edit! file T}   T{ e
  181. e!  T}   T{
  182. Clears the editor buffer and then copies into it  the  named  file,
  183. which  becomes  the  current  file.  This is a way of shifting to a
  184. different file without leaving the editor.   The  editor  issues  a
  185. warning  message if this command is used before saving changes made
  186. to the file already in the buffer; using the form e! overrides this
  187. protective mechanism.  T}   T{
  188. :e ch10
  189. No write since last change
  190. :e! ch10
  191. "ch10" 3 lines, 62 characters
  192. :
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. T}
  203.  
  204. file  name f    T{  If followed by a name, renames the current file
  205. to name.  If used without name, prints  the  name  of  the  current
  206. file.  T}   T{
  207. :f ch9
  208. "ch9" [Modified] 3 lines ...
  209. :f
  210. "ch9" [Modified] 3 lines ...
  211. :
  212. T}
  213.  
  214. (1,$)global    g    global/pattern/commands  T{
  215. :g/nonsense/d
  216. :
  217. T} (1,$)global!   g! or v   T{ Searches the entire buffer (unless a
  218. smaller range is specified by line-number  prefixes)  and  executes
  219. commands  on  every  line with an expression matching pattern.  The
  220. second form, abbreviated either g! or v, executes commands on lines
  221. that do not contain the expression pattern.  T}
  222.  
  223. (.)insert i    T{  Inserts new lines of text immediately before the
  224. specified line.  Differs from append only in that  text  is  placed
  225. before,  rather than after, the indicated line.  In other words, 1i
  226. has the same effect as 0a.  T}   T{
  227. :1i
  228. These lines of text will
  229. be added prior to line 1.
  230. .
  231. :
  232. T}
  233.  
  234. (.,.+1)join    j    T{ Join lines together, adjusting  white  space
  235. (spaces and tabs) as necessary.  T}   T{
  236. :2,5j
  237. Resulting line is printed
  238. :
  239. T}
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. cp10  cp10  cp10  cp10 ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
  269. Name Abbr Description    Examples
  270.  
  271.  
  272. (.,.)list l    T{ Prints lines in a more unambiguous way  than  the
  273. print  command does. The end of a line, for example, is marked with
  274. a ``$'', and tabs printed as ``^I''.  T}   T{
  275. :9l
  276. This is line 9$
  277. :
  278. T}
  279.  
  280.  
  281. ltw(1.0i)    lt2w(0.40i)fB    ltw(3.0i)    ltw(1.8i).     (.,.)move
  282. addr m    T{ Moves the specified lines to a position after the line
  283. indicated by addr.  T}   T{
  284. :12,15m 25
  285. New current line is printed
  286. :
  287. T}
  288.  
  289. (.,.)number    nu   T{ Prints each line preceded by its buffer line
  290. number.  T}   T{
  291. :nu
  292.   10  This is line 10
  293. :
  294. T}
  295.  
  296. (.)open   o    T{  Too  involved  to discuss here, but if you enter
  297. open mode accidentally, press the ESC key followed by q to get back
  298. into normal editor command mode.  Edit is designed to prevent acci-
  299. dental use of the open command.  T}
  300.  
  301. preserve  pre  T{ Saves a copy of the current  buffer  contents  as
  302. though  the  system  had just crashed.  This is for use in an emer-
  303. gency when a write command has failed and you don't know  how  else
  304. to save your work.- T}   T{
  305. :preserve
  306. File preserved.
  307. :
  308. T}
  309.  
  310. (.,.)print     p    Prints the text of line(s).   T{
  311. :+2,+3p
  312. The second and third lines
  313. after the current line
  314. :
  315. T}
  316.  
  317.  
  318.  
  319. ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).
  320. T{
  321. quit
  322. quit!
  323. T}   T{
  324. q
  325. q!
  326. -----------
  327. -  Seek assistance from a consultant as soon as possible
  328. after saving a file with the preserve  command,  because
  329. the  file  is saved on system storage space for only one
  330. week.
  331.  
  332.  
  333.  
  334. T}   T{
  335. Ends the editing session.  You will receive a warning if  you  have
  336. changed  the buffer since last writing its contents to the file. In
  337. this event you must either type w to write, or type q! to exit from
  338. the editor without saving your changes.  T}   T{
  339. :q
  340. No write since last change
  341. :q!
  342. %
  343. T}
  344.  
  345. (.)read file   r    T{
  346. Places  a  copy  of  file  in  the buffer after the specified line.
  347. Address 0 is permissible and causes the copy of file to  be  placed
  348. at  the  beginning  of the buffer.  The read command does not erase
  349. any text already in the buffer.  If no line  number  is  specified,
  350. file is placed after the current line.  T}   T{
  351. :0r newfile
  352. "newfile" 5 lines, 86 characters
  353. :
  354. T}
  355.  
  356. recover file   rec  T{
  357. Retrieves  a copy of the editor buffer after a system crash, editor
  358. crash, phone line disconnection, or preserve command.  T}
  359.  
  360. (.,.)substitute     s    T{
  361. substitute/pattern/replacement/
  362. substitute/pattern/replacement/gc
  363. Replaces the first occurrence of pattern on a  line  with  replace-
  364. ment.   Including  a g after the command changes all occurrences of
  365. pattern on the line.  The c option allows the user to confirm  each
  366. substitution  before  it  is  made;  see  the  manual  for details.
  367. T}   T{
  368. :3p
  369. Line 3 contains a misstake
  370. :s/misstake/mistake/
  371. Line 3 contains a mistake
  372. :
  373. T}
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. cp10 cp10 cp10 cp10 ltw(1.0i)  lt2w(0.40i)fB  ltw(3.0i)  ltw(1.8i).
  401. Name Abbr Description    Examples
  402.  
  403.  
  404. undo u    T{
  405. Reverses  the changes made in the buffer by the last buffer-editing
  406. command.  Note that this example contains a notification about  the
  407. number of lines affected.  T}   T{
  408. :1,15d
  409. 15 lines deleted
  410. new line number 1 is printed
  411. :u
  412. 15 more lines in file ...
  413. old line number 1 is printed
  414. :
  415. T}
  416.  
  417. (1,$)write file     w    T{
  418. Copies  data  from  the buffer onto a permanent file. If no file is
  419. named, the current filename is used.   The  file  is  automatically
  420. created if it does not yet exist.  A response containing the number
  421. of lines and characters in the file indicates that  the  write  has
  422. been  completed  successfully.   The  editor's built-in protections
  423. against overwriting  existing  files  will  in  some  circumstances
  424. inhibit  a write.  The form w! forces the write, confirming that an
  425. existing file is to be overwritten.  T}   T{
  426. :w
  427. "file7" 64 lines, 1122 characters
  428. :w file8
  429. "file8" File exists ...
  430. :w! file8
  431. "file8" 64 lines, 1122 characters
  432. :
  433. T} (1,$)write! file    w!
  434.  
  435.  
  436. ltw(1.0i)     lt2w(0.40i)fB     ltw(3.0i)     ltw(1.8i).       (.)z
  437. count     z    T{
  438. Prints  a screen full of text starting with the line indicated; or,
  439. if count is specified, prints that number of  lines.   Variants  of
  440. the z command are described in the manual.  T}
  441.  
  442. !command       T{
  443. Executes  the remainder of the line after ! as a UNIX command.  The
  444. buffer is unchanged by this, and control is returned to the  editor
  445. when the execution of command is complete.  T}   T{
  446. :!date
  447. Fri Jun 9 12:15:11 PDT 1978
  448. !
  449. :
  450. T}
  451.  
  452. control-d      T{
  453. Prints  the next scroll of text, normally half of a screen. See the
  454. manual for details of the scroll option.  T}
  455.  
  456. (.+1)<cr>      T{
  457. An address alone followed by a carriage return causes the  line  to
  458. be  printed.  A carriage return by itself prints the line following
  459. the current line.  T}   T{
  460. :<cr>
  461. the line after the current line
  462. :
  463.  
  464.  
  465.  
  466. T}
  467.  
  468.  
  469. ltw(1.0i) lt2w(0.40i)fB ltw(3.0i) ltw(1.8i).  /pattern/      T{
  470. Searches for the next line in which pattern occurs and  prints  it.
  471. T}   T{
  472. :/This pattern/
  473. This pattern next occurs here.
  474. :
  475. T}
  476.  
  477. //        T{ Repeats the most recent search.  T}   T{
  478. ://
  479. This pattern also occurs here.
  480. :
  481. T}
  482.  
  483. ?pattern?      T{  Searches  in  the reverse direction for pattern.
  484. T}
  485.  
  486. ??        T{ Repeats the most recent search, moving in the  reverse
  487. direction through the buffer.  T}
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.