home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / riscbsd / datafile / usd / 14_edit / edittut_ms < prev   
Encoding:
Text File  |  1996-10-12  |  65.6 KB  |  2,245 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                 Edit:  A Tutorial
  8.  
  9.                     Ricki Blau
  10.  
  11.                    James Joyce
  12.  
  13.                 Computing Services
  14.              University of California
  15.             Berkeley, California 94720
  16.  
  17.  
  18.  
  19.                      ABSTRACT
  20.  
  21.  
  22. This narrative introduction to the use of the text
  23. editor edit assumes no prior familiarity with com-
  24. puters  or  with text editing.  Its aim is to lead
  25. the beginning UNIX- user through  the  fundamental
  26. steps  of  writing  and  revising  a file of text.
  27. Edit,  a  version  of  the  text  editor  ex,  was
  28. designed to provide an informative environment for
  29. new and casual users.
  30.  
  31.      We welcome  comments  and  suggestions  about
  32. this  tutorial  and the UNIX documentation in gen-
  33. eral.
  34. September 1981
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. -----------
  60. -UNIX is a trademark of Bell Laboratories.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. USD:14-2                                    Edit: A Tutorial
  71.  
  72.  
  73.                             Contents
  74.  
  75. Introduction   3
  76.  
  77. Session 1  4
  78.      Making contact with UNIX   4
  79.      Logging in  4
  80.      Asking for edit   4
  81.      The ``Command not found'' message   5
  82.      A summary  5
  83.      Entering text   5
  84.      Messages from edit   5
  85.      Text input mode   6
  86.      Making corrections   6
  87.      Writing text to disk   7
  88.      Signing off  7
  89.  
  90. Session 2   8
  91.      Adding more text to the file   8
  92.      Interrupt   8
  93.      Making corrections   8
  94.      Listing what's in the buffer (p)   9
  95.      Finding things in the buffer   9
  96.      The current line   10
  97.      Numbering lines (nu)   10
  98.      Substitute command (s)   10
  99.      Another way to list what's in the buffer (z)   11
  100.      Saving the modified text   12
  101.  
  102. Session 3   13
  103.      Bringing text into the buffer (e)   13
  104.      Moving text in the buffer (m)   13
  105.      Copying lines (copy)   14
  106.      Deleting lines (d)   14
  107.      A word or two of caution   15
  108.      Undo (u) to the rescue   15
  109.      More about the dot (.) and buffer end ($)   16
  110.      Moving around in the buffer (+ and -)   16
  111.      Changing lines (c)   17
  112.  
  113. Session 4   18
  114.      Making commands global (g)   18
  115.      More about searching and substituting   19
  116.      Special characters   19
  117.      Issuing UNIX commands from the editor   20
  118.      Filenames and file manipulation   20
  119.      The file (f) command   20
  120.      Reading additional files (r)   21
  121.      Writing parts of the buffer   21
  122.      Recovering files   21
  123.      Other recovery techniques   21
  124.      Further reading and other information   22
  125.      Using ex   22
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. Edit: A Tutorial                                         USD:14-3
  137.  
  138.  
  139. Index   23
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. USD:14-4                                         Edit: A Tutorial
  203.  
  204.  
  205.                           Introduction
  206.  
  207.      Text editing using a terminal connected to a computer allows
  208. you to create, modify, and print text easily.  A text editor is a
  209. program that assists you as you create and modify text.  The text
  210. editor  you  will  learn here is named edit.  Creating text using
  211. edit is as easy as typing it on an electric typewriter.   Modify-
  212. ing  text  involves telling the text editor what you want to add,
  213. change, or delete.  You can review your text by typing a  command
  214. to  print  the file contents as they are currently.  Another pro-
  215. gram (which we do not discuss in this document), a  text  format-
  216. ter, rearranges your text for you into ``finished form.''
  217.  
  218.      These  lessons assume no prior familiarity with computers or
  219. with text editing.  They consist of a series of text editing ses-
  220. sions  which  lead  you through the fundamental steps of creating
  221. and revising text.  After scanning each lesson and before  begin-
  222. ning the next, you should try the examples at a terminal to get a
  223. feeling for the actual process of text editing.  If you set aside
  224. some time for experimentation, you will soon become familiar with
  225. using the computer to write and modify text.  In addition to  the
  226. actual  use  of  the  text editor, other features of UNIX will be
  227. very important to your work.  You can begin to learn about  these
  228. other features by reading one of the other tutorials that provide
  229. a general introduction to the system.  You will be ready to  pro-
  230. ceed  with  this lesson as soon as you are familiar with (1) your
  231. terminal and its special keys, (2) how to login, (3) and the ways
  232. of correcting typing errors.  Let's first define some terms:
  233.  
  234. program     A   set  of  instructions,  given  to  the  computer,
  235.             describing the sequence of steps  the  computer  per-
  236.             forms  in  order  to accomplish a specific task.  The
  237.             task must be specific, such as balancing your  check-
  238.             book  or  editing your text.  A general task, such as
  239.             working for world peace, is something we can all  do,
  240.             but  not something we can currently write programs to
  241.             do.
  242.  
  243. UNIX        UNIX is a special type of program, called an  operat-
  244.             ing  system,  that  supervises  the machinery and all
  245.             other programs comprising the total computer  system.
  246.  
  247. edit        edit  is the name of the UNIX text editor you will be
  248.             learning to use, and is a program that  aids  you  in
  249.             writing  or  revising  text.   Edit  was designed for
  250.             beginning users, and is a simplified  version  of  an
  251.             editor named ex.
  252.  
  253. file        Each UNIX account is allotted space for the permanent
  254.             storage of information, such  as  programs,  data  or
  255.             text.  A file is a logical unit of data, for example,
  256.             an essay, a program, or a chapter from a book,  which
  257.             is  stored  on  a computer system.  Once you create a
  258.             file, it is kept until you  instruct  the  system  to
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. Edit: A Tutorial                                         USD:14-5
  269.  
  270.  
  271.             remove  it.   You  may  create a file during one UNIX
  272.             session, end the session, and return to use it  at  a
  273.             later  time.   Files  contain  anything you choose to
  274.             write and store in them.  The sizes of files vary  to
  275.             suit  your  needs;  one file might hold only a single
  276.             number, yet another might contain a very  long  docu-
  277.             ment  or  program.   The only way to save information
  278.             from one session to the next is  to  store  it  in  a
  279.             file, which you will learn in Session 1.
  280.  
  281. filename    Filenames  are  used  to  distinguish  one  file from
  282.             another, serving the same purpose as  the  labels  of
  283.             manila  folders in a file cabinet.  In order to write
  284.             or access information in a file, you use the name  of
  285.             that  file  in  a  UNIX  command, and the system will
  286.             automatically locate the file.
  287.  
  288. disk        Files are stored on an input/output device  called  a
  289.             disk,  which  looks  something like a stack of phono-
  290.             graph records.  Each surface is coated with  a  mate-
  291.             rial  similar to that on magnetic recording tape, and
  292.             information is recorded on it.
  293.  
  294. buffer      A temporary work space, made available  to  the  user
  295.             for  the  duration  of  a session of text editing and
  296.             used for creating and modifying the  text  file.   We
  297.             can  think  of  the  buffer  as  a blackboard that is
  298.             erased after each class, where each session with  the
  299.             editor is a class.
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. USD:14-6                                         Edit: A Tutorial
  335.  
  336.  
  337.                             Session 1
  338.  
  339.  
  340. Making contact with UNIX
  341.  
  342.      To  use the editor you must first make contact with the com-
  343. puter by logging in to UNIX.  We'll quickly review  the  standard
  344. UNIX  login procedure for the two ways you can make contact: on a
  345. terminal that is directly linked to the computer, or over a tele-
  346. phone line where the computer answers your call.
  347.  
  348. Directly-linked terminals
  349.  
  350.      Turn on your terminal and press the RETURN key.  You are now
  351. ready to login.
  352.  
  353. Dial-up terminals
  354.  
  355.      If your terminal connects with the computer over a telephone
  356. line,  turn  on the terminal, dial the system access number, and,
  357. when you hear a high-pitched tone, place the telephone handset in
  358. the acoustic coupler, if you are using one.  You are now ready to
  359. login.
  360.  
  361. Logging in
  362.  
  363.      The message inviting you to login is:
  364.  
  365.           login:
  366.  
  367.  
  368. Type your login name, which identifies you to UNIX, on  the  same
  369. line as the login message, and press RETURN.  If the terminal you
  370. are using has both upper and lower case, be sure you  enter  your
  371. login  name  in  lower case; otherwise UNIX assumes your terminal
  372. has only upper case and will not recognize lower case letters you
  373. may  type.   UNIX  types ``login:'' and you reply with your login
  374. name, for example ``susan'':
  375.  
  376.           login: susan (and press the RETURN key)
  377.  
  378. (In the examples, input you would type appears in  bold  face  to
  379. distinguish it from the responses from UNIX.)
  380.  
  381.      UNIX  will  next respond with a request for a password as an
  382. additional precaution to prevent unauthorized people  from  using
  383. your  account.  The password will not appear when you type it, to
  384. prevent others from seeing it.  The message is:
  385.  
  386.           Password:    (type your password and press RETURN)
  387.  
  388. If any of the information you gave during the login sequence  was
  389. mistyped or incorrect, UNIX will respond with
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. Edit: A Tutorial                                         USD:14-7
  401.  
  402.  
  403.           Login incorrect.
  404.  
  405.           login:
  406.  
  407. in  which case you should start the login process anew.  Assuming
  408. that you have successfully logged in, UNIX will print the message
  409. of the day and eventually will present you with a % at the begin-
  410. ning of a fresh line.  The % is  the  UNIX  prompt  symbol  which
  411. tells you that UNIX is ready to accept a command.
  412.  
  413. Asking for edit
  414.  
  415.      You  are ready to tell UNIX that you want to work with edit,
  416. the text editor.  Now is a convenient time to choose a  name  for
  417. the  file of text you are about to create.  To begin your editing
  418. session, type edit followed by a space and then the filename  you
  419. have  selected;  for  example,  ``text''.   After that, press the
  420. RETURN key and wait for edit's response:
  421.  
  422.           % edit text    (followed by a RETURN)
  423.           "text" No such file or directory
  424.           :
  425.  
  426. If you typed the command correctly, you will now be in communica-
  427. tion  with edit.  Edit has set aside a buffer for use as a tempo-
  428. rary working space during your current  editing  session.   Since
  429. ``text''  is  a  new  file  we are about to create the editor was
  430. unable to find that file, which it confirms by saying:
  431.  
  432.           "text" No such file or directory
  433.  
  434. On the next line appears edit's prompt ``:'', announcing that you
  435. are in command mode and edit expects a command from you.  You may
  436. now begin to create the new file.
  437.  
  438. The ``Command not found'' message
  439.  
  440.      If you misspelled edit  by  typing,  say,  ``editor'',  this
  441. might appear:
  442.  
  443.           % editor
  444.           editor: Command not found
  445.           %
  446.  
  447. Your  mistake in calling edit ``editor'' was treated by UNIX as a
  448. request for a program named ``editor''.  Since there is  no  pro-
  449. gram  named  ``editor'', UNIX reported that the program was ``not
  450. found''.  A new % indicates that UNIX is ready for  another  com-
  451. mand, and you may then enter the correct command.
  452.  
  453. A summary
  454.  
  455.      Your  exchange  with  UNIX as you logged in and made contact
  456. with edit should look something like this:
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. USD:14-8                                         Edit: A Tutorial
  467.  
  468.  
  469.           login: susan
  470.           Password:
  471.           ... A Message of General Interest ...
  472.           % edit text
  473.           "text" No such file or directory
  474.           :
  475.  
  476.  
  477. Entering text
  478.  
  479.      You may now begin entering text into the  buffer.   This  is
  480. done  by  appending  (or adding) text to whatever is currently in
  481. the buffer.  Since there is nothing in the buffer at the  moment,
  482. you  are  appending  text  to  nothing;  in effect, since you are
  483. adding text to nothing you are creating text.  Most edit commands
  484. have  two equivalent forms: a word that suggests what the command
  485. does, and a shorter abbreviation of that  word.   Many  beginners
  486. find the full command names easier to remember at first, but once
  487. you are familiar with editing you may prefer to type the  shorter
  488. abbreviations.  The command to input text is ``append''.  (It may
  489. be abbreviated ``a''.)  Type append and press the RETURN key.
  490.  
  491.           % edit text
  492.           :append
  493.  
  494.  
  495. Messages from edit
  496.  
  497.      If you make a mistake in entering a command and  type  some-
  498. thing that edit does not recognize, edit will respond with a mes-
  499. sage intended to help you diagnose your error.  For  example,  if
  500. you  misspell  the  command  to  input  text  by typing, perhaps,
  501. ``add'' instead of ``append'' or ``a'',  you  will  receive  this
  502. message:
  503.  
  504.           :add
  505.           add: Not an editor command
  506.           :
  507.  
  508. When  you  receive  a diagnostic message, check what you typed in
  509. order to determine what part of your command confused edit.   The
  510. message  above  means  that  edit  was  unable  to recognize your
  511. mistyped command and, therefore, did not execute it.  Instead,  a
  512. new  ``:''  appeared  to let you know that edit is again ready to
  513. execute a command.
  514.  
  515. Text input mode
  516.  
  517.      By giving the command ``append'' (or using the  abbreviation
  518. ``a''),  you  entered text input mode, also known as append mode.
  519. When you enter text input mode, edit stops sending you a  prompt.
  520. You  will not receive any prompts or error messages while in text
  521. input mode.  You can enter pretty much anything you want  on  the
  522. lines.   The  lines  are transmitted one by one to the buffer and
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. Edit: A Tutorial                                         USD:14-9
  533.  
  534.  
  535. held there during the editing session.  You may  append  as  much
  536. text  as  you want, and when you wish to stop entering text lines
  537. you should type a period as the only character on  the  line  and
  538. press the RETURN key.  When you type the period and press RETURN,
  539. you signal that  you  want  to  stop  appending  text,  and  edit
  540. responds by allowing you to exit text input mode and reenter com-
  541. mand mode.  Edit will again prompt you for a command by  printing
  542. ``:''.
  543.  
  544.      Leaving append mode does not destroy the text in the buffer.
  545. You have to leave append mode to do any of  the  other  kinds  of
  546. editing, such as changing, adding, or printing text.  If you type
  547. a period as the first character and type any other  character  on
  548. the  same  line,  edit  will believe you want to remain in append
  549. mode and will not let you out.  As this can be very  frustrating,
  550. be sure to type only the period and the RETURN key.
  551.  
  552.      This is a good place to learn an important lesson about com-
  553. puters and text:  a blank space is a character as far as  a  com-
  554. puter  is concerned.  If you so much as type a period followed by
  555. a blank (that is, type a period and then the  space  bar  on  the
  556. keyboard),  you  will remain in append mode with the last line of
  557. text being:
  558.  
  559.           .
  560.  
  561. Let's say that you enter the lines (try to type exactly what  you
  562. see, including ``thiss''):
  563.  
  564.           This is some sample text.
  565.           And thiss is some more text.
  566.           Text editing is strange, but nice.
  567.           .
  568.  
  569. The  last  line  is the period followed by a RETURN that gets you
  570. out of append mode.
  571.  
  572. Making corrections
  573.  
  574.      If you have read a general introduction to  UNIX,  you  will
  575. recall  that  it is possible to erase individual letters that you
  576. have typed.  This is done by typing the designated erase  charac-
  577. ter as many times as there are characters you want to erase.
  578.  
  579.      The  usual  erase  character  varies from place to place and
  580. user to user.  Often it is the backspace (control-H), so you  can
  581. correct  typing errors in the line you are typing by holding down
  582. the CTRL key and typing the ``H'' key.  (Sometimes it is the  DEL
  583. key.)   If  you type the erase character you will notice that the
  584. terminal backspaces in the line you are on.   You  can  backspace
  585. over  your  error,  and then type what you want to be the rest of
  586. the line.
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. USD:14-10                                        Edit: A Tutorial
  599.  
  600.  
  601.      If you make a bad start in a line and would  like  to  begin
  602. again,  you  can either backspace to the beginning of the line or
  603. you can use the at-sign ``@'' to erase everything on the line:
  604.  
  605.           Text edtiing is strange, but@
  606.           Text editing is strange, but nice.
  607.  
  608. When you type the at-sign (@), you erase the entire line typed so
  609. far  and  are given a fresh line to type on.  You may immediately
  610. begin to retype the line.  This,  unfortunately,  does  not  work
  611. after you type the line and press RETURN.  To make corrections in
  612. lines that have been completed, it is necessary to use the  edit-
  613. ing commands covered in the next sessions.
  614.  
  615. Writing text to disk
  616.  
  617.      You are now ready to edit the text.  One common operation is
  618. to write the text to disk as a file  for  safekeeping  after  the
  619. session  is  over.  This is the only way to save information from
  620. one session to the next, since the editor's buffer  is  temporary
  621. and  will last only until the end of the editing session.  Learn-
  622. ing how to write a file to disk is second in importance  only  to
  623. entering the text.  To write the contents of the buffer to a disk
  624. file, use the command ``write'' (or its abbreviation ``w''):
  625.  
  626.           :write
  627.  
  628. Edit will copy the contents of the buffer to a disk file.  If the
  629. file does not yet exist, a new file will be created automatically
  630. and the presence of a ``[New file]'' will be noted.   The  newly-
  631. created  file  will  be given the name specified when you entered
  632. the editor, in this case ``text''.  To confirm that the disk file
  633. has  been successfully written, edit will repeat the filename and
  634. give the number of lines and the total number  of  characters  in
  635. the file.  The buffer remains unchanged by the ``write'' command.
  636. All of the lines that were written to disk will still be  in  the
  637. buffer, should you want to modify or add to them.
  638.  
  639.      Edit  must  have  a name for the file to be written.  If you
  640. forgot to indicate the name of the file when you began  to  edit,
  641. edit will print in response to your write command:
  642.  
  643.           No current filename
  644.  
  645. If this happens, you can specify the filename in a new write com-
  646. mand:
  647.  
  648.           :write text
  649.  
  650. After the ``write'' (or ``w''), type a space and then the name of
  651. the file.
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. Edit: A Tutorial                                        USD:14-11
  665.  
  666.  
  667. Signing off
  668.  
  669.      We  have done enough for this first lesson on using the UNIX
  670. text editor, and are ready to quit the session with edit.  To  do
  671. this we type ``quit'' (or ``q'') and press RETURN:
  672.  
  673.           :write
  674.           "text" [New file]  3 lines, 90 characters
  675.           :quit
  676.           %
  677.  
  678. The  %  is  from  UNIX to tell you that your session with edit is
  679. over and you may command UNIX further.  Since we want to end  the
  680. entire  session  at the terminal, we also need to exit from UNIX.
  681. In response to the UNIX prompt of ``%'' type the command
  682.  
  683.           %logout
  684.  
  685. This will end your session with UNIX, and will ready the terminal
  686. for  the next user.  It is always important to type logout at the
  687. end of a session to make absolutely sure no  one  could  acciden-
  688. tally stumble into your abandoned session and thus gain access to
  689. your files, tempting even the most honest of souls.
  690.  
  691.  
  692.      This is the end of the first session on UNIX text editing.
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. USD:14-12                                        Edit: A Tutorial
  731.  
  732.  
  733.                             Session 2
  734.  
  735.  
  736.      Login with UNIX as in the first session:
  737.  
  738.           login: susan  (carriage return)
  739.           Password:       (give password and carriage return)
  740.  
  741.           ... A Message of General Interest ...
  742.           %
  743.  
  744. When you indicate you want to edit, you can specify the  name  of
  745. the  file you worked on last time.  This will start edit working,
  746. and it will fetch the contents of the file into  the  buffer,  so
  747. that  you can resume editing the same file.  When edit has copied
  748. the file into the buffer, it will repeat its name  and  tell  you
  749. the number of lines and characters it contains.  Thus,
  750.  
  751.           % edit text
  752.           "text" 3 lines, 90 characters
  753.           :
  754.  
  755. means  you  asked edit to fetch the file named ``text'' for edit-
  756. ing, causing it to copy  the  90  characters  of  text  into  the
  757. buffer.   Edit  awaits  your  further instructions, and indicates
  758. this by its prompt character, the colon (:).  In this session, we
  759. will  append  more  text  to  our file, print the contents of the
  760. buffer, and learn to change the text of a line.
  761.  
  762. Adding more text to the file
  763.  
  764.      If you want to add more to the end of your text you  may  do
  765. so  by  using  the append command to enter text input mode.  When
  766. ``append'' is the first command  of  your  editing  session,  the
  767. lines  you enter are placed at the end of the buffer.  Here we'll
  768. use the abbreviation for the append command, ``a'':
  769.  
  770.           :a
  771.           This is text added in Session 2.
  772.           It doesn't mean much here, but
  773.           it does illustrate the editor.
  774.           .
  775.  
  776. You may recall that once you enter append mode  using  the  ``a''
  777. (or  ``append'') command, you need to type a line containing only
  778. a period (.)  to exit append mode.
  779.  
  780. Interrupt
  781.  
  782.      Should you press the RUB  key  (sometimes  labelled  DELETE)
  783. while working with edit, it will send this message to you:
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. Edit: A Tutorial                                        USD:14-13
  797.  
  798.  
  799.           Interrupt
  800.           :
  801.  
  802. Any  command that edit might be executing is terminated by rub or
  803. delete, causing edit to prompt you for a new command.  If you are
  804. appending text at the time, you will exit from append mode and be
  805. expected to give another command.  The line of text you were typ-
  806. ing  when  the append command was interrupted will not be entered
  807. into the buffer.
  808.  
  809. Making corrections
  810.  
  811.      If while typing the line you hit an  incorrect  key,  recall
  812. that  you may delete the incorrect character or cancel the entire
  813. line of input by erasing in the usual way.  Refer either  to  the
  814. last  few pages of Session 1 if you need to review the procedures
  815. for making a correction.  The most important idea to remember  is
  816. that erasing a character or cancelling a line must be done before
  817. you press the RETURN key.
  818.  
  819. Listing what's in the buffer (p)
  820.  
  821.      Having appended text to what you wrote  in  Session  1,  you
  822. might want to see all the lines in the buffer.  To print the con-
  823. tents of the buffer, type the command:
  824.  
  825.           :1,$p
  826.  
  827. The  ``1''-  stands for line 1 of the buffer, the ``$'' is a spe-
  828. cial symbol designating the last line of the  buffer,  and  ``p''
  829. (or  print) is the command to print from line 1 to the end of the
  830. buffer.  The command ``1,$p'' gives you:
  831.  
  832.           This is some sample text.
  833.           And thiss is some more text.
  834.           Text editing is strange, but nice.
  835.           This is text added in Session 2.
  836.           It doesn't mean much here, but
  837.           it does illustrate the editor.
  838.  
  839. Occasionally, you may accidentally type a character that can't be
  840. printed,  which  can be done by striking a key while the CTRL key
  841. is pressed.  In printing lines, edit uses a special  notation  to
  842. show  the  existence of non-printing characters.  Suppose you had
  843. introduced the non-printing character ``control-A'' into the word
  844. ``illustrate''  by  accidently pressing the CTRL key while typing
  845. ``a''.  This can happen on many terminals because  the  CTRL  key
  846. and  the ``A'' key are beside each other.  If your finger presses
  847. between the two keys, control-A results.  When asked to print the
  848. contents of the buffer, edit would display
  849.  
  850. -----------
  851. -The numeral ``one'' is the top left-most key, and
  852. should not be confused with the letter ``el''.
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. USD:14-14                                        Edit: A Tutorial
  863.  
  864.  
  865.           it does illustr^Ate the editor.
  866.  
  867. To  represent  the  control-A,  edit  shows ``^A''.  The sequence
  868. ``^'' followed by a capital letter stands for the  one  character
  869. entered  by holding down the CTRL key and typing the letter which
  870. appears after the ``^''.  We'll soon discuss  the  commands  that
  871. can be used to correct this typing error.
  872.  
  873.      In  looking  over  the text we see that ``this'' is typed as
  874. ``thiss'' in the second line, a deliberate error so we can  learn
  875. to make corrections.  Let's correct the spelling.
  876.  
  877. Finding things in the buffer
  878.  
  879.      In  order to change something in the buffer we first need to
  880. find it.  We can find ``thiss'' in the text we  have  entered  by
  881. looking  at  a  listing  of  the  lines.  Physically speaking, we
  882. search the lines of text looking for ``thiss'' and stop searching
  883. when  we have found it.  The way to tell edit to search for some-
  884. thing is to type it inside slash marks:
  885.  
  886.           :/thiss/
  887.  
  888. By typing /thiss/ and  pressing  RETURN,  you  instruct  edit  to
  889. search  for  ``thiss''.  If you ask edit to look for a pattern of
  890. characters which it cannot find in the buffer,  it  will  respond
  891. ``Pattern not found''.  When edit finds the characters ``thiss'',
  892. it will print the line of text for your inspection:
  893.  
  894.           And thiss is some more text.
  895.  
  896. Edit is now positioned in the buffer at the line it just printed,
  897. ready to make a change in the line.
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. Edit: A Tutorial                                        USD:14-15
  929.  
  930.  
  931. The current line
  932.  
  933.      Edit  keeps  track  of  the  line  in the buffer where it is
  934. located at all times during an editing session.  In general,  the
  935. line  that has been most recently printed, entered, or changed is
  936. the current location in the buffer.  The editor  is  prepared  to
  937. make  changes  at  the current location in the buffer, unless you
  938. direct it to another location.
  939.  
  940.      In particular, when you bring a file into  the  buffer,  you
  941. will  be  located  at the last line in the file, where the editor
  942. left off copying the lines from the file to the buffer.  If  your
  943. first  editing  command  is  ``append'',  the lines you enter are
  944. added to the end of the file, after the current line -- the  last
  945. line in the file.
  946.  
  947.      You  can refer to your current location in the buffer by the
  948. symbol period (.) usually known by the name ``dot''.  If you type
  949. ``.''  and  carriage return you will be instructing edit to print
  950. the current line:
  951.  
  952.           :.
  953.           And thiss is some more text.
  954.  
  955.  
  956.      If you want to know the number of the current line, you  can
  957. type  .=  and  press  RETURN, and edit will respond with the line
  958. number:
  959.  
  960.           :.=
  961.           2
  962.  
  963. If you type the number of any line and press  RETURN,  edit  will
  964. position you at that line and print its contents:
  965.  
  966.           :2
  967.           And thiss is some more text.
  968.  
  969. You  should  experiment with these commands to gain experience in
  970. using them to make changes.
  971.  
  972. Numbering lines (nu)
  973.  
  974.      The number (nu) command is similar to print, giving both the
  975. number  and the text of each printed line.  To see the number and
  976. the text of the current line type
  977.  
  978.           :nu
  979.                2  And thiss is some more text.
  980.  
  981. Note that the shortest abbreviation for  the  number  command  is
  982. ``nu''  (and  not  ``n'', which is used for a different command).
  983. You may specify a range of lines to be listed by the number  com-
  984. mand  in  the  same  way that lines are specified for print.  For
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. USD:14-16                                        Edit: A Tutorial
  995.  
  996.  
  997. example, 1,$nu lists all lines in the buffer  with  their  corre-
  998. sponding line numbers.
  999.  
  1000. Substitute command (s)
  1001.  
  1002.      Now  that you have found the misspelled word, you can change
  1003. it from ``thiss'' to ``this''.  As  far  as  edit  is  concerned,
  1004. changing  things  is  a  matter  of  substituting  one  thing for
  1005. another.  As a stood for append, so s stands for substitute.   We
  1006. will use the abbreviation ``s'' to reduce the chance of mistyping
  1007. the substitute command.  This command will instruct edit to  make
  1008. the change:
  1009.  
  1010.           2s/thiss/this/
  1011.  
  1012. We  first  indicate the line to be changed, line 2, and then type
  1013. an ``s'' to indicate we want edit to make a substitution.  Inside
  1014. the  first  set  of  slashes  are  the characters that we want to
  1015. change, followed by the characters to replace them,  and  then  a
  1016. closing slash mark.  To summarize:
  1017.  
  1018.           2s/ what is to be changed / what to change it to /
  1019.  
  1020. If  edit  finds an exact match of the characters to be changed it
  1021. will make the change only in the first occurrence of the  charac-
  1022. ters.   If it does not find the characters to be changed, it will
  1023. respond:
  1024.  
  1025.           Substitute pattern match failed
  1026.  
  1027. indicating that your instructions could not be carried out.  When
  1028. edit  does  find  the characters that you want to change, it will
  1029. make the substitution and automatically print the  changed  line,
  1030. so that you can check that the correct substitution was made.  In
  1031. the example,
  1032.  
  1033.           :2s/thiss/this/
  1034.           And this is some more text.
  1035.  
  1036. line 2 (and line 2 only) will  be  searched  for  the  characters
  1037. ``thiss'',  and  when  the  first exact match is found, ``thiss''
  1038. will be changed to ``this''.  Strictly speaking, it was not  nec-
  1039. essary  above  to  specify  the number of the line to be changed.
  1040. In
  1041.  
  1042.           :s/thiss/this/
  1043.  
  1044. edit will assume that we mean to change the  line  where  we  are
  1045. currently  located  (``.'').  In this case, the command without a
  1046. line number would have produced the same result because  we  were
  1047. already located at the line we wished to change.
  1048.  
  1049.      For  another  illustration of the substitute command, let us
  1050. choose the line:
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. Edit: A Tutorial                                        USD:14-17
  1061.  
  1062.  
  1063.           Text editing is strange, but nice.
  1064.  
  1065. You can make this line a bit more  positive  by  taking  out  the
  1066. characters ``strange, but '' so the line reads:
  1067.  
  1068.           Text editing is nice.
  1069.  
  1070. A  command  that will first position edit at the desired line and
  1071. then make the substitution is:
  1072.  
  1073.           :/strange/s/strange, but //
  1074.  
  1075.  
  1076. What we have done here is combine our search with  our  substitu-
  1077. tion.   Such combinations are perfectly legal, and speed up edit-
  1078. ing quite a bit once you get used to them.  That is, you  do  not
  1079. necessarily  have to use line numbers to identify a line to edit.
  1080. Instead, you may identify the line you want to change  by  asking
  1081. edit  to search for a specified pattern of letters that occurs in
  1082. that line.  The parts of the above command are:
  1083.  
  1084.           /strange/          tells edit to find the characters ``strange'' in the text
  1085.           s                  tells edit to make a substitution
  1086.           /strange, but //   substitutes nothing at all for the characters ``strange, but ''
  1087.  
  1088.  
  1089.      You should note the space after ``but'' in  ``/strange,  but
  1090. /''.   If  you do not indicate that the space is to be taken out,
  1091. your line will read:
  1092.  
  1093.           Text editing is  nice.
  1094.  
  1095. which looks a little funny because of  the  extra  space  between
  1096. ``is''  and  ``nice''.   Again, we realize from this that a blank
  1097. space is a real character to a computer, and in editing  text  we
  1098. need  to  be  aware  of  spaces within a line just as we would be
  1099. aware of an ``a'' or a ``4''.
  1100.  
  1101. Another way to list what's in the buffer (z)
  1102.  
  1103.      Although the print command is useful for looking at specific
  1104. lines  in  the  buffer, other commands may be more convenient for
  1105. viewing large sections of text.  You can ask to see a screen full
  1106. of text at a time by using the command z.  If you type
  1107.  
  1108.           :1z
  1109.  
  1110. edit will start with line 1 and continue printing lines, stopping
  1111. either when the screen of your terminal is full or when the  last
  1112. line  in  the  buffer  has been printed.  If you want to read the
  1113. next segment of text, type the command
  1114.  
  1115.           :z
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. USD:14-18                                        Edit: A Tutorial
  1127.  
  1128.  
  1129. If no starting line number is given for the z  command,  printing
  1130. will  start  at  the ``current'' line, in this case the last line
  1131. printed.  Viewing lines in the buffer one screen full at  a  time
  1132. is  known  as paging.  Paging can also be used to print a section
  1133. of text on a hard-copy terminal.
  1134.  
  1135. Saving the modified text
  1136.  
  1137.      This seems to be a good place to pause in our work,  and  so
  1138. we  should  end the second session.  If you (in haste) type ``q''
  1139. to quit the session your dialogue with edit will be:
  1140.  
  1141.           :q
  1142.           No write since last change (:quit! overrides)
  1143.           :
  1144.  
  1145. This is edit's warning that you have  not  written  the  modified
  1146. contents  of  the buffer to disk.  You run the risk of losing the
  1147. work you did during the editing session since you typed the  lat-
  1148. est write command.  Because in this lesson we have not written to
  1149. disk at all, everything we have done would have been lost if edit
  1150. had  obeyed  the q command.  If you did not want to save the work
  1151. done during this editing session, you would have to  type  ``q!''
  1152. or (``quit!'')  to confirm that you indeed wanted to end the ses-
  1153. sion immediately, leaving the file  as  it  was  after  the  most
  1154. recent  ``write''  command.  However, since you want to save what
  1155. you have edited, you need to type:
  1156.  
  1157.           :w
  1158.           "text" 6 lines, 171 characters
  1159.  
  1160. and then follow with the commands to quit and logout:
  1161.  
  1162.           :q
  1163.           % logout
  1164.  
  1165. and hang up the phone or turn off the terminal when UNIX asks for
  1166. a name.  Terminals connected to the port selector will stop after
  1167. the logout command, and pressing keys on  the  keyboard  will  do
  1168. nothing.
  1169.  
  1170.  
  1171.      This  is the end of the second session on UNIX text editing.
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. Edit: A Tutorial                                        USD:14-19
  1193.  
  1194.  
  1195.                             Session 3
  1196.  
  1197. Bringing text into the buffer (e)
  1198.  
  1199.      Login to UNIX and make contact with edit.  You should try to
  1200. login  without  looking at the notes, but if you must then by all
  1201. means do.
  1202.  
  1203.      Did you remember to give the name of the file you wanted  to
  1204. edit?  That is, did you type
  1205.  
  1206.           % edit text
  1207.  
  1208. or simply
  1209.  
  1210.           % edit
  1211.  
  1212. Both  ways  get  you in contact with edit, but the first way will
  1213. bring a copy of the file named ``text'' into the buffer.  If  you
  1214. did  forget  to  tell  edit the name of your file, you can get it
  1215. into the buffer by typing:
  1216.  
  1217.           :e text
  1218.           "text" 6 lines, 171 characters
  1219.  
  1220. The command edit, which may be abbreviated e, tells edit that you
  1221. want  to  erase  anything that might already be in the buffer and
  1222. bring a copy of the file ``text'' into the  buffer  for  editing.
  1223. You may also use the edit (e) command to change files in the mid-
  1224. dle of an editing session, or to give edit the name of a new file
  1225. that  you  want  to  create.  Because the edit command clears the
  1226. buffer, you will receive a warning if you try to edit a new  file
  1227. without  having  saved  a copy of the old file.  This gives you a
  1228. chance to write the contents of the buffer to disk before editing
  1229. the next file.
  1230.  
  1231. Moving text in the buffer (m)
  1232.  
  1233.      Edit  allows  you to move lines of text from one location in
  1234. the buffer to another by means of  the  move  (m)  command.   The
  1235. first  two  examples  are for illustration only, though after you
  1236. have read this Session you are welcome  to  return  to  them  for
  1237. practice.  The command
  1238.  
  1239.           :2,4m$
  1240.  
  1241. directs  edit  to move lines 2, 3, and 4 to the end of the buffer
  1242. ($).  The format for the move command is  that  you  specify  the
  1243. first  line to be moved, the last line to be moved, the move com-
  1244. mand ``m'', and the line after which the  moved  text  is  to  be
  1245. placed.  So,
  1246.  
  1247.           :1,3m6
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. USD:14-20                                        Edit: A Tutorial
  1259.  
  1260.  
  1261. would  instruct  edit  to move lines 1 through 3 (inclusive) to a
  1262. location after line 6 in the buffer.  To move only one line, say,
  1263. line  4,  to  a  location in the buffer after line 5, the command
  1264. would be ``4m5''.
  1265.  
  1266.      Let's move some text using the command:
  1267.  
  1268.           :5,$m1
  1269.           2 lines moved
  1270.           it does illustrate the editor.
  1271.  
  1272. After executing a command that moves more than one  line  of  the
  1273. buffer,  edit  tells how many lines were affected by the move and
  1274. prints the last moved line for your inspection.  If you  want  to
  1275. see more than just the last line, you can then use the print (p),
  1276. z, or number (nu) command to view more text.  The  buffer  should
  1277. now contain:
  1278.  
  1279.           This is some sample text.
  1280.           It doesn't mean much here, but
  1281.           it does illustrate the editor.
  1282.           And this is some more text.
  1283.           Text editing is nice.
  1284.           This is text added in Session 2.
  1285.  
  1286. You can restore the original order by typing:
  1287.  
  1288.           :4,$m1
  1289.  
  1290. or, combining context searching and the move command:
  1291.  
  1292.           :/And this is some/,/This is text/m/This is some sample/
  1293.  
  1294. (Do  not  type  both  examples here!)  The problem with combining
  1295. context searching with the move command is that  your  chance  of
  1296. making  a  typing error in such a long command is greater than if
  1297. you type line numbers.
  1298.  
  1299. Copying lines (copy)
  1300.  
  1301.      The copy command is used to make a second copy of  specified
  1302. lines,  leaving the original lines where they were.  Copy has the
  1303. same format as the move command, for example:
  1304.  
  1305.           :2,5copy $
  1306.  
  1307. makes a copy of lines 2 through 5, placing the added lines  after
  1308. the  buffer's  end ($).  Experiment with the copy command so that
  1309. you can become familiar with how it works.  Note that the  short-
  1310. est  abbreviation for copy is co (and not the letter ``c'', which
  1311. has another meaning).
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. Edit: A Tutorial                                        USD:14-21
  1325.  
  1326.  
  1327. Deleting lines (d)
  1328.  
  1329.      Suppose you want to delete the line
  1330.  
  1331.           This is text added in Session 2.
  1332.  
  1333. from the buffer.  If you know  the  number  of  the  line  to  be
  1334. deleted,  you can type that number followed by delete or d.  This
  1335. example deletes line 4, which is ``This is text added in  Session
  1336. 2.''  if you typed the commands suggested so far.
  1337.  
  1338.           :4d
  1339.           It doesn't mean much here, but
  1340.  
  1341. Here  ``4''  is  the  number  of  the  line  to  be  deleted, and
  1342. ``delete'' or ``d'' is the command to  delete  the  line.   After
  1343. executing  the  delete  command,  edit  prints  the line that has
  1344. become the current line (``.'').
  1345.  
  1346.      If you do not happen to know the line number you can  search
  1347. for the line and then delete it using this sequence of commands:
  1348.  
  1349.           :/added in Session 2./
  1350.           This is text added in Session 2.
  1351.           :d
  1352.           It doesn't mean much here, but
  1353.  
  1354. The  ``/added  in Session 2./'' asks edit to locate and print the
  1355. line containing the indicated text, starting its  search  at  the
  1356. current  line  and  moving  line by line until it finds the text.
  1357. Once you are sure that you have correctly specified the line  you
  1358. want  to  delete,  you can enter the delete (d) command.  In this
  1359. case it is not necessary to specify  a  line  number  before  the
  1360. ``d''.  If no line number is given, edit deletes the current line
  1361. (``.''), that is, the line found by our search.  After the  dele-
  1362. tion, your buffer should contain:
  1363.  
  1364.           This is some sample text.
  1365.           And this is some more text.
  1366.           Text editing is nice.
  1367.           It doesn't mean much here, but
  1368.           it does illustrate the editor.
  1369.           And this is some more text.
  1370.           Text editing is nice.
  1371.           This is text added in Session 2.
  1372.           It doesn't mean much here, but
  1373.  
  1374. To delete both lines 2 and 3:
  1375.  
  1376.           And this is some more text.
  1377.           Text editing is nice.
  1378.  
  1379. you type
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. USD:14-22                                        Edit: A Tutorial
  1391.  
  1392.  
  1393.           :2,3d
  1394.           2 lines deleted
  1395.  
  1396. which specifies the range of lines from 2 to 3, and the operation
  1397. on those lines -- ``d'' for delete.  If you delete more than  one
  1398. line  you  will receive a message telling you the number of lines
  1399. deleted, as indicated in the example above.
  1400.  
  1401.      The previous example assumes that you know the line  numbers
  1402. for the lines to be deleted.  If you do not you might combine the
  1403. search command with the delete command:
  1404.  
  1405.           :/And this is some/,/Text editing is nice./d
  1406.  
  1407.  
  1408. A word or two of caution
  1409.  
  1410.      In using the search function to locate lines to  be  deleted
  1411. you  should  be  absolutely  sure  the characters you give as the
  1412. basis for the search will take edit to the line you want deleted.
  1413. Edit  will  search  for  the  first  occurrence of the characters
  1414. starting from where you last edited - that is, from the line  you
  1415. see printed if you type dot (.).
  1416.  
  1417.      A search based on too few characters may result in the wrong
  1418. lines being deleted, which edit will do as easily as if  you  had
  1419. meant  it.   For  this reason, it is usually safer to specify the
  1420. search and then delete in two separate steps, at least until  you
  1421. become  familiar enough with using the editor that you understand
  1422. how best to specify searches.  For a beginner it  is  not  a  bad
  1423. idea  to double-check each command before pressing RETURN to send
  1424. the command on its way.
  1425.  
  1426. Undo (u) to the rescue
  1427.  
  1428.      The undo (u) command has the ability to reverse the  effects
  1429. of  the last command that changed the buffer.  To undo the previ-
  1430. ous command, type ``u'' or ``undo''.  Undo can  rescue  the  con-
  1431. tents  of  the buffer from many an unfortunate mistake.  However,
  1432. its powers are not unlimited, so it is still wise to  be  reason-
  1433. ably careful about the commands you give.
  1434.  
  1435.      It is possible to undo only commands which have the power to
  1436. change the buffer -- for example,  delete,  append,  move,  copy,
  1437. substitute,  and  even  undo  itself.  The commands write (w) and
  1438. edit (e), which interact with disk files, cannot be  undone,  nor
  1439. can  commands that do not change the buffer, such as print.  Most
  1440. importantly, the only command that can be reversed by undo is the
  1441. last  ``undo-able'' command you typed.  You can use control-H and
  1442. @ to change commands while you  are  typing  them,  and  undo  to
  1443. reverse  the effect of the commands after you have typed them and
  1444. pressed RETURN.
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. Edit: A Tutorial                                        USD:14-23
  1457.  
  1458.  
  1459.      To illustrate, let's issue an undo command.  Recall that the
  1460. last  buffer-changing  command we gave deleted the lines formerly
  1461. numbered 2 and 3.  Typing undo at this moment  will  reverse  the
  1462. effects  of  the deletion, causing those two lines to be replaced
  1463. in the buffer.
  1464.  
  1465.           :u
  1466.           2 more lines in file after undo
  1467.           And this is some more text.
  1468.  
  1469. Here again, edit informs you if the command affects more than one
  1470. line,  and  prints the text of the line which is now ``dot'' (the
  1471. current line).
  1472.  
  1473. More about the dot (.) and buffer end ($)
  1474.  
  1475.      The function assumed by the symbol dot depends on  its  con-
  1476. text.  It can be used:
  1477.  
  1478.      1.   to  exit from append mode; we type dot (and only a dot)
  1479.      on a line and press RETURN;
  1480.  
  1481.      2.  to refer to the line we are at in the buffer.
  1482.  
  1483. Dot can also be combined with the equal sign to get the number of
  1484. the line currently being edited:
  1485.  
  1486.           :.=
  1487.  
  1488. If  we  type ``.='' we are asking for the number of the line, and
  1489. if we type ``.'' we are asking for the text of the line.
  1490.  
  1491.      In this editing session and the last,  we  used  the  dollar
  1492. sign to indicate the end of the buffer in commands such as print,
  1493. copy, and move.  The dollar sign as a command asks edit to  print
  1494. the last line in the buffer.  If the dollar sign is combined with
  1495. the equal sign ($=) edit will print the line number corresponding
  1496. to the last line in the buffer.
  1497.  
  1498.      ``.''  and  ``$'',  then,  represent line numbers.  Whenever
  1499. appropriate, these symbols can be used in place of  line  numbers
  1500. in commands.  For example
  1501.  
  1502.           :.,$d
  1503.  
  1504. instructs  edit to delete all lines from the current line (.)  to
  1505. the end of the buffer.
  1506.  
  1507. Moving around in the buffer  (+ and -)
  1508.  
  1509.      When you are editing you often want to go back and re-read a
  1510. previous line.  You could specify a context search for a line you
  1511. want to read if you remember some of its text, but if you  simply
  1512. want  to  see  what  was written a few, say 3, lines ago, you can
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. USD:14-24                                        Edit: A Tutorial
  1523.  
  1524.  
  1525. type
  1526.  
  1527.           -3p
  1528.  
  1529. This tells edit to move back to a position  3  lines  before  the
  1530. current  line  (.)  and print that line.  You can move forward in
  1531. the buffer similarly:
  1532.  
  1533.           +2p
  1534.  
  1535. instructs edit to print the line that is 2 ahead of your  current
  1536. position.
  1537.  
  1538.      You  may  use  ``+''  and  ``-''  in  any command where edit
  1539. accepts line numbers.  Line numbers specified with ``+'' or ``-''
  1540. can be combined to print a range of lines.  The command
  1541.  
  1542.           :-1,+2copy$
  1543.  
  1544. makes  a  copy of 4 lines:  the current line, the line before it,
  1545. and the two after it.  The copied lines will be placed after  the
  1546. last  line  in the buffer ($), and the original lines referred to
  1547. by ``-1'' and ``+2'' remain where they are.
  1548.  
  1549.      Try typing only ``-''; you will move back one line  just  as
  1550. if  you  had typed ``-1p''.  Typing the command ``+'' works simi-
  1551. larly.  You might also try typing a few plus or minus signs in  a
  1552. row  (such  as  ``+++'')  to  see edit's response.  Typing RETURN
  1553. alone on a line is the equivalent of typing ``+1p''; it will move
  1554. you one line ahead in the buffer and print that line.
  1555.  
  1556.      If  you  are  at the last line of the buffer and try to move
  1557. further ahead, perhaps by typing a ``+''  or  a  carriage  return
  1558. alone  on  the line, edit will remind you that you are at the end
  1559. of the buffer:
  1560.  
  1561.           At end-of-file
  1562. or
  1563.           Not that many lines in buffer
  1564.  
  1565. Similarly, if you try to move to  a  position  before  the  first
  1566. line, edit will print one of these messages:
  1567.  
  1568.           Nonzero address required on this command
  1569. or
  1570.           Negative address - first buffer line is 1
  1571.  
  1572. The   number   associated  with  a  buffer  line  is  the  line's
  1573. ``address'', in that it can be used to locate the line.
  1574.  
  1575. Changing lines (c)
  1576.  
  1577.      You can also delete certain lines and  insert  new  text  in
  1578. their place.  This can be accomplished easily with the change (c)
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. Edit: A Tutorial                                        USD:14-25
  1589.  
  1590.  
  1591. command.  The change command instructs edit to  delete  specified
  1592. lines  and then switch to text input mode to accept the text that
  1593. will replace them.  Let's say you want to change  the  first  two
  1594. lines in the buffer:
  1595.  
  1596.           This is some sample text.
  1597.           And this is some more text.
  1598.  
  1599. to read
  1600.  
  1601.           This text was created with the UNIX text editor.
  1602.  
  1603. To do so, you type:
  1604.  
  1605.           :1,2c
  1606.           2 lines changed
  1607.           This text was created with the UNIX text editor.
  1608.           .
  1609.           :
  1610.  
  1611. In  the  command 1,2c we specify that we want to change the range
  1612. of lines beginning with 1 and ending with 2 by giving  line  num-
  1613. bers  as  with  the  print command.  These lines will be deleted.
  1614. After you type RETURN to end the change  command,  edit  notifies
  1615. you  if more than one line will be changed and places you in text
  1616. input mode.  Any text  typed  on  the  following  lines  will  be
  1617. inserted into the position where lines were deleted by the change
  1618. command.  You will remain in text input mode until  you  exit  in
  1619. the usual way, by typing a period alone on a line.  Note that the
  1620. number of lines added to the buffer need not be the same  as  the
  1621. number of lines deleted.
  1622.  
  1623.  
  1624.      This  is  the  end of the third session on text editing with
  1625. UNIX.
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. USD:14-26                                        Edit: A Tutorial
  1655.  
  1656.  
  1657.                             Session 4
  1658.  
  1659.  
  1660.      This lesson covers several topics,  starting  with  commands
  1661. that  apply  throughout the buffer, characters with special mean-
  1662. ings, and how to issue UNIX commands while in  the  editor.   The
  1663. next  topics  deal  with  files: more on reading and writing, and
  1664. methods of recovering files lost in a crash.  The  final  section
  1665. suggests sources of further information.
  1666.  
  1667. Making commands global (g)
  1668.  
  1669.      One  disadvantage to the commands we have used for searching
  1670. or substituting is that if you have a number of  instances  of  a
  1671. word  to  change  it  appears  that  you have to type the command
  1672. repeatedly, once for each time  the  change  needs  to  be  made.
  1673. Edit,  however,  provides  a  way  to  make commands apply to the
  1674. entire contents of the buffer - the global (g) command.
  1675.  
  1676.      To print all lines containing a certain sequence of  charac-
  1677. ters (say, ``text'') the command is:
  1678.  
  1679.           :g/text/p
  1680.  
  1681. The ``g'' instructs edit to make a global search for all lines in
  1682. the buffer containing the characters  ``text''.  The ``p'' prints
  1683. the lines found.
  1684.  
  1685.      To  issue a global command, start by typing a ``g'' and then
  1686. a search pattern identifying the lines to be affected.  Then,  on
  1687. the same line, type the command to be executed for the identified
  1688. lines.  Global substitutions are frequently useful.  For example,
  1689. to  change all instances of the word ``text'' to the word ``mate-
  1690. rial'' the command would be a combination of  the  global  search
  1691. and the substitute command:
  1692.  
  1693.           :g/text/s/text/material/g
  1694.  
  1695. Note  the ``g'' at the end of the global command, which instructs
  1696. edit to change each and every instance  of  ``text''  to  ``mate-
  1697. rial''.   If  you do not type the ``g'' at the end of the command
  1698. only the first instance of ``text'' in each line will be  changed
  1699. (the  normal result of the substitute command).  The ``g'' at the
  1700. end of the command is independent of the ``g'' at the  beginning.
  1701. You may give a command such as:
  1702.  
  1703.           :5s/text/material/g
  1704.  
  1705. to  change  every instance of ``text'' in line 5 alone.  Further,
  1706. neither command will change ``text'' to ``material'' if  ``Text''
  1707. begins with a capital rather than a lower-case t.
  1708.  
  1709.      Edit  does  not  automatically print the lines modified by a
  1710. global command.  If you want the lines  to  be  printed,  type  a
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. Edit: A Tutorial                                        USD:14-27
  1721.  
  1722.  
  1723. ``p'' at the end of the global command:
  1724.  
  1725.           :g/text/s/text/material/gp
  1726.  
  1727. You  should be careful about using the global command in combina-
  1728. tion with any other - in essence, be sure of what you are telling
  1729. edit to do to the entire buffer.  For example,
  1730.  
  1731.           :g/ /d
  1732.           72 less lines in file after global
  1733.  
  1734. will  delete  every line containing a blank anywhere in it.  This
  1735. could adversely affect  your  document,  since  most  lines  have
  1736. spaces  between words and thus would be deleted.  After executing
  1737. the global command, edit will print  a  warning  if  the  command
  1738. added  or deleted more than one line.  Fortunately, the undo com-
  1739. mand can reverse the effects of a  global  command.   You  should
  1740. experiment with the global command on a small file of text to see
  1741. what it can do for you.
  1742.  
  1743. More about searching and substituting
  1744.  
  1745.      In using slashes to identify a character string that we want
  1746. to search for or change, we have always specified the exact char-
  1747. acters.  There is a less tedious way to repeat the same string of
  1748. characters.  To change ``text'' to ``texts'' we may type either
  1749.  
  1750.           :/text/s/text/texts/
  1751.  
  1752. as we have done in the past, or a somewhat abbreviated command:
  1753.  
  1754.           :/text/s//texts/
  1755.  
  1756. In this example, the characters to be changed are not specified -
  1757. there are no characters, not even a space, between the two  slash
  1758. marks  that indicate what is to be changed.  This lack of charac-
  1759. ters between the slashes is taken by the editor to mean ``use the
  1760. characters   we  last  searched  for  as  the  characters  to  be
  1761. changed.''
  1762.  
  1763.      Similarly, the last context search may be repeated by typing
  1764. a pair of slashes with nothing between them:
  1765.  
  1766.           :/does/
  1767.           It doesn't mean much here, but
  1768.           ://
  1769.           it does illustrate the editor.
  1770.  
  1771. (You  should  note  that  the search command found the characters
  1772. ``does'' in the word ``doesn't'' in the  first  search  request.)
  1773. Because  no  characters  are specified for the second search, the
  1774. editor scans the buffer for the next occurrence of the characters
  1775. ``does''.
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. USD:14-28                                        Edit: A Tutorial
  1787.  
  1788.  
  1789.      Edit  normally searches forward through the buffer, wrapping
  1790. around from the end of the buffer to  the  beginning,  until  the
  1791. specified  character  string  is found.  If you want to search in
  1792. the reverse direction, use question marks (?) instead of  slashes
  1793. to surround the characters you are searching for.
  1794.  
  1795.      It  is also possible to repeat the last substitution without
  1796. having to retype the entire command.  An ampersand (&) used as  a
  1797. command  repeats  the  most  recent substitute command, using the
  1798. same search and replacement patterns.  After altering the current
  1799. line by typing
  1800.  
  1801.           :s/text/texts/
  1802.  
  1803. you type
  1804.  
  1805.           :/text/&
  1806.  
  1807. or simply
  1808.  
  1809.           ://&
  1810.  
  1811. to make the same change on the next line in the buffer containing
  1812. the characters ``text''.
  1813.  
  1814. Special characters
  1815.  
  1816.      Two characters have special meanings when used in specifying
  1817. searches:  ``$'' and ``^''.  ``$'' is taken by the editor to mean
  1818. ``end of the line'' and is used to identify strings that occur at
  1819. the end of a line.
  1820.  
  1821.           :g/text.$/s//material./p
  1822.  
  1823. tells  the  editor  to  search  for all lines ending in ``text.''
  1824. (and nothing else, not even a blank space), to change each  final
  1825. ``text.'' to ``material.'', and print the changed lines.
  1826.  
  1827.      The symbol ``^'' indicates the beginning of a line.  Thus,
  1828.  
  1829.           :s/^/1. /
  1830.  
  1831. instructs  the  editor to insert ``1.'' and a space at the begin-
  1832. ning of the current line.
  1833.  
  1834.      The characters ``$'' and ``^'' have special meanings only in
  1835. the  context  of  searching.   At  other times, they are ordinary
  1836. characters.  If you ever need to search for a character that  has
  1837. a  special  meaning,  you  must indicate that the character is to
  1838. lose temporarily its special significance by typing another  spe-
  1839. cial character, the backslash (\), before it.
  1840.  
  1841.           :s/\\$/dollar/
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. Edit: A Tutorial                                        USD:14-29
  1853.  
  1854.  
  1855. looks for the character ``$'' in the current line and replaces it
  1856. by the word ``dollar''.  Were it not for the backslash, the ``$''
  1857. would  have  represented  ``the  end of the line'' in your search
  1858. rather than the character ``$''.  The backslash retains its  spe-
  1859. cial significance unless it is preceded by another backslash.
  1860.  
  1861. Issuing UNIX commands from the editor
  1862.  
  1863.      After  creating  several files with the editor, you may want
  1864. to delete files no longer useful to you or ask for a list of your
  1865. files.   Removing and listing files are not functions of the edi-
  1866. tor, and so they require the use of UNIX  system  commands  (also
  1867. referred  to  as  ``shell'' commands, as ``shell'' is the name of
  1868. the program that processes UNIX commands).  You do  not  need  to
  1869. quit the editor to execute a UNIX command as long as you indicate
  1870. that it is to be sent to the shell for  execution.   To  use  the
  1871. UNIX command rm to remove the file named ``junk'' type:
  1872.  
  1873.           :!rm junk
  1874.           !
  1875.           :
  1876.  
  1877. The  exclamation mark (!)  indicates that the rest of the line is
  1878. to be processed as a shell command.  If the buffer contents  have
  1879. not been written since the last change, a warning will be printed
  1880. before the command is executed:
  1881.  
  1882.           [No write since last change]
  1883.  
  1884. The editor prints a ``!'' when the command is  completed.   Other
  1885. tutorials  describe  useful  features  of the system, of which an
  1886. editor is only one part.
  1887.  
  1888. Filenames and file manipulation
  1889.  
  1890.      Throughout each editing session, edit  keeps  track  of  the
  1891. name  of  the  file  being  edited as the current filename.  Edit
  1892. remembers as the current filename the name given when you entered
  1893. the  editor.   The current filename changes whenever the edit (e)
  1894. command is used to specify a new file.  Once edit has recorded  a
  1895. current  filename,  it inserts that name into any command where a
  1896. filename has been omitted.  If a write command does not specify a
  1897. file,  edit,  as we have seen, supplies the current filename.  If
  1898. you are editing a file named ``draft3'' having 283 lines  in  it,
  1899. you  can have the editor write onto a different file by including
  1900. its name in the write command:
  1901.  
  1902.           :w chapter3
  1903.           "chapter3" [new file] 283 lines, 8698 characters
  1904.  
  1905. The current filename remembered by the editor will not be changed
  1906. as  a  result of the write command.  Thus, if the next write com-
  1907. mand does not specify a name, edit will write  onto  the  current
  1908. file (``draft3'') and not onto the file ``chapter3''.
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. USD:14-30                                        Edit: A Tutorial
  1919.  
  1920.  
  1921. The file (f) command
  1922.  
  1923.      To  ask  for  the  current  filename,  type file (or f).  In
  1924. response, the  editor  provides  current  information  about  the
  1925. buffer, including the filename, your current position, the number
  1926. of lines in the buffer, and the percent of the  distance  through
  1927. the file your current location is.
  1928.  
  1929.           :f
  1930.           "text" [Modified] line 3 of 4 --75%--
  1931.  
  1932. If  the  contents  of the buffer have changed since the last time
  1933. the file was written, the editor will tell you that the file  has
  1934. been  ``[Modified]''.  After you save the changes by writing onto
  1935. a disk file, the buffer will no longer be considered modified:
  1936.  
  1937.           :w
  1938.           "text" 4 lines, 88 characters
  1939.           :f
  1940.           "text" line 3 of 4 --75%--
  1941.  
  1942.  
  1943. Reading additional files (r)
  1944.  
  1945.      The read (r) command allows you to add  the  contents  of  a
  1946. file  to  the buffer at a specified location, essentially copying
  1947. new lines between two existing lines.  To  use  it,  specify  the
  1948. line  after  which the new text will be placed, the read (r) com-
  1949. mand, and then the name of the file.  If you have  a  file  named
  1950. ``example'', the command
  1951.  
  1952.           :$r example
  1953.           "example" 18 lines, 473 characters
  1954.  
  1955. reads  the  file  ``example'' and adds it to the buffer after the
  1956. last line.  The current filename is not changed by the read  com-
  1957. mand.
  1958.  
  1959. Writing parts of the buffer
  1960.  
  1961.      The write (w) command can write all or part of the buffer to
  1962. a file you specify.  We are already  familiar  with  writing  the
  1963. entire contents of the buffer to a disk file.  To write only part
  1964. of the buffer onto a file,  indicate  the  beginning  and  ending
  1965. lines before the write command, for example
  1966.  
  1967.           :45,$w ending
  1968.  
  1969. Here  all lines from 45 through the end of the buffer are written
  1970. onto the file named ending.  The lines remain in  the  buffer  as
  1971. part  of  the  document  you are editing, and you may continue to
  1972. edit the entire buffer.  Your original file is unaffected by your
  1973. command  to write part of the buffer to another file.  Edit still
  1974. remembers whether you have saved changes to the  buffer  in  your
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. Edit: A Tutorial                                        USD:14-31
  1985.  
  1986.  
  1987. original file or not.
  1988.  
  1989. Recovering files
  1990.  
  1991.      Although it does not happen very often, there are times UNIX
  1992. stops working because of some  malfunction.   This  situation  is
  1993. known  as a crash.  Under most circumstances, edit's crash recov-
  1994. ery feature is able to save work to within a few lines of changes
  1995. before a crash (or an accidental phone hang up).  If you lose the
  1996. contents of an editing buffer in a system crash,  you  will  nor-
  1997. mally  receive  mail  when  you  login that gives the name of the
  1998. recovered file.  To recover the file, enter the editor  and  type
  1999. the command recover (rec), followed by the name of the lost file.
  2000. For example, to recover the buffer for an edit session  involving
  2001. the file ``chap6'', the command is:
  2002.  
  2003.           :recover chap6
  2004.  
  2005. Recover  is  sometimes  unable to save the entire buffer success-
  2006. fully, so always check the contents of the saved buffer carefully
  2007. before writing it back onto the original file.  For best results,
  2008. write the buffer to a new file temporarily so you can examine  it
  2009. without risk to the original file.  Unfortunately, you cannot use
  2010. the recover command to retrieve a  file  you  removed  using  the
  2011. shell command rm.
  2012.  
  2013. Other recovery techniques
  2014.  
  2015.      If  something  goes  wrong when you are using the editor, it
  2016. may be possible to save your work by using the  command  preserve
  2017. (pre),  which  saves the buffer as if the system had crashed.  If
  2018. you  are  writing  a  file  and  you  get  the  message   ``Quota
  2019. exceeded'',  you  have  tried  to  use  more disk storage than is
  2020. allotted to your account.  Proceed with  caution  because  it  is
  2021. likely  that only a part of the editor's buffer is now present in
  2022. the file you tried to write.  In this case  you  should  use  the
  2023. shell  escape from the editor (!)  to remove some files you don't
  2024. need and try to write the file again.  If this  is  not  possible
  2025. and you cannot find someone to help you, enter the command
  2026.  
  2027.           :preserve
  2028.  
  2029. and wait for the reply,
  2030.  
  2031.           File preserved.
  2032.  
  2033. If  you do not receive this reply, seek help immediately.  Do not
  2034. simply leave the editor.  If you do, the buffer will be lost, and
  2035. you  may  not  be able to save your file.  If the reply is ``File
  2036. preserved.''  you can leave the editor (or logout) to remedy  the
  2037. situation.   After  a  preserve,  you can use the recover command
  2038. once the problem has been corrected, or the -r option of the edit
  2039. command if you leave the editor and want to return.
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. USD:14-32                                        Edit: A Tutorial
  2051.  
  2052.  
  2053.      If  you  make an undesirable change to the buffer and type a
  2054. write command before discovering your mistake, the modified  ver-
  2055. sion  will  replace any previous version of the file.  Should you
  2056. ever lose a good version of a document in this way, do not  panic
  2057. and  leave  the  editor.   As long as you stay in the editor, the
  2058. contents of the  buffer  remain  accessible.   Depending  on  the
  2059. nature  of  the problem, it may be possible to restore the buffer
  2060. to a more complete state with the undo command.  After fixing the
  2061. damaged buffer, you can again write the file to disk.
  2062.  
  2063. Further reading and other information
  2064.  
  2065.      Edit  is  an editor designed for beginning and casual users.
  2066. It is actually a version of a more  powerful  editor  called  ex.
  2067. These lessons are intended to introduce you to the editor and its
  2068. more commonly-used commands.  We have not covered all of the edi-
  2069. tor's commands, but a selection of commands that should be suffi-
  2070. cient to accomplish most of your editing tasks.  You can find out
  2071. more about the editor in the Ex Reference Manual, which is appli-
  2072. cable to both ex and edit.  One way to become familiar  with  the
  2073. manual  is  to  begin by reading the description of commands that
  2074. you already know.
  2075.  
  2076. Using ex
  2077.  
  2078.      As you become more experienced with using  the  editor,  you
  2079. may  still find that edit continues to meet your needs.  However,
  2080. should you become interested in using ex, it is easy  to  switch.
  2081. To begin an editing session with ex, use the name ex in your com-
  2082. mand instead of edit.
  2083.  
  2084.      Edit commands also work in ex, but the  editing  environment
  2085. is  somewhat different.  You should be aware of a few differences
  2086. between ex and edit.  In edit, only the characters ``^'',  ``$'',
  2087. and  ``\'' have special meanings in searching the buffer or indi-
  2088. cating characters to be changed by a substitute command.  Several
  2089. additional  characters  have special meanings in ex, as described
  2090. in the Ex Reference Manual.  Another feature of the edit environ-
  2091. ment  prevents  users  from  accidently  entering two alternative
  2092. modes of editing, open and visual, in which  the  editor  behaves
  2093. quite  differently from normal command mode.  If you are using ex
  2094. and you encounter  strange  behavior,  you  may  have  accidently
  2095. entered  open  mode by typing ``o''.  Type the ESC key and then a
  2096. ``Q'' to get out of open or visual mode and back into the regular
  2097. editor  command  mode.   The  document An Introduction to Display
  2098. Editing with Vi provide full details of visual mode.
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. Edit: A Tutorial                                        USD:14-33
  2117.  
  2118.  
  2119.                               Index
  2120.  
  2121.  
  2122.  
  2123. addressing, see line numbers         //, 12, 20
  2124. ampersand, 20                        ??, 20
  2125. append mode, 6-7                     ., 11, 17
  2126. append (a) command, 6, 7, 9          .=, 11, 17
  2127. ``At end of file'' (message), 18   entering text, 3, 6-7
  2128. backslash (\), 21                  erasing
  2129. buffer, 3                            characters (^H), 7
  2130. caret (^), 10, 20                    lines (@), 7
  2131. change (c) command, 18             error corrections, 7, 16
  2132. command mode, 5-6                  ex (text editor), 23
  2133. ``Command not found'' (message), 6 Ex Reference Manual, 23
  2134. context search, 10-12, 19-21       exclamation (!), 21
  2135. control characters (``^'' notation)file, 3
  2136. control-H, 7                       file (f) command, 21-22
  2137. copy (co) command, 15              file recovery, 22-23
  2138. corrections, 7, 16                 filename, 3, 21
  2139. current filename, 21               global (g) command, 19
  2140. current line (.), 11, 17           input mode, 6-7
  2141. delete (d) command, 15-16          Interrupt (message), 9
  2142. dial-up, 5                         line numbers, see also current line
  2143. disk, 3                              dollar sign ($), 10, 11, 17
  2144. documentation, 3, 23                 dot (.), 11, 17
  2145. dollar ($), 10, 11, 17, 20-21        relative (+ and -), 17
  2146. dot (.) 11, 17                     list, 10
  2147. edit (text editor), 3, 5, 23       logging in, 4-6
  2148. edit (e) command, 5, 9, 14         logging out, 8
  2149. editing commands:                  ``Login incorrect'' (message), 5
  2150.   append (a), 6, 7, 9              minus (-), 17
  2151.   change (c), 18                   move (m) command, 14-15
  2152.   copy (co), 15                    ``Negative address--first buffer line is 1'' (message), 18
  2153.   delete (d), 15-16                ``No current filename'' (message), 8
  2154.   edit (text editor), 3, 5, 23     ``No such file or directory'' (message), 5, 6
  2155.   edit (e), 5, 9, 14               ``No write since last change'' (message), 21
  2156.   file (f), 21-22                  non-printing characters, 10
  2157.   global (g), 19                   ``Nonzero address required'' (message), 18
  2158.   move (m), 14-15                  ``Not an editor command'' (message), 6
  2159.   number (nu), 11                  ``Not that many lines in buffer'' (message), 18
  2160.   preserve (pre), 22-23            number (nu) command, 11
  2161.   print (p), 10                    password, 5
  2162.   quit (q), 8, 13                  period (.), 11, 17
  2163.   read (r), 22                     plus (+), 17
  2164.   recover (rec), 22, 23            preserve (pre) command, 22-23
  2165.   substitute (s), 11-12, 19, 20    print (p) command, 10
  2166.   undo (u), 16-17, 23              program, 3
  2167.   write (w), 8, 13, 21, 22         prompts
  2168.   z, 12-13                           % (UNIX), 5
  2169.   ! (shell escape), 21               : (edit), 5, 6, 7
  2170.   $=, 17                               (append), 7
  2171.   +, 17                            question (?), 20
  2172.   -, 17                            quit (q) command, 8, 13
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. USD:14-34                                        Edit: A Tutorial
  2183.  
  2184.  
  2185. read (r) command, 22
  2186. recover (rec) command, 22, 23
  2187. recovery, see file recovery
  2188. references, 3, 23
  2189. remove (rm) command, 21, 22
  2190. reverse command effects (undo), 16-17, 23
  2191. searching, 10-12, 19-21
  2192. shell, 21
  2193. shell escape (!), 21
  2194. slash (/), 11-12, 20
  2195. special characters (^, $, \), 10, 11, 17, 20-21
  2196. substitute (s) command, 11-12, 19, 20
  2197. terminals, 4-5
  2198. text input mode, 7
  2199. undo (u) command, 16-17, 23
  2200. UNIX, 3
  2201. write (w) command, 8, 13, 21, 22
  2202. z command, 12-13
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.