 
 
                              19-Sep-80 5:42:29 Ued Page 1
 
 
      A  Tutorial  Introduction  to the
 RSX Text Editor.                              We  will  assume  that  you  have
                                          logged in to RSX and it has just  said
                                          ">".  The easiest way to get UED is to
 Introduction                             type
 
      UED  is a "text editor", that is,        E       (followed by a newline)
 an interactive  program  for  creating
 and modifying "text", using directions        You are now ready to go - UED  is
 provided  by a user at a terminal. The   waiting for you to tell it what to do.
 text is often  a  document  like  this
 one,  or a program or perhaps data for
 a program.                               Creating Text - the Append command "a"
 
      This  introduction  is  meant  to        As  our first problem, suppose we
 simplify learning UED. The recommended   want to create some text starting from
 way  to  learn  UED  is  to  read this   scratch. Perhaps  we  are  typing  the
 document, simultaneously using UED  to   very  first  draft of a paper; clearly
 follow  the examples, then to read the   it will have to start  somewhere,  and
 UED reference manual, all the while ex   undergo   modifications   later.  This
 perimenting with UED. (Solicitation of   section will show how to get some text
 advice from experinced users  is  also   in, just to get started. Later we will
 useful.)                                 talk about how to change it.
 
      Do   the  exercises!  They  cover        When UED is first started, it  is
 material not completely  discussed  in   rather like working with a blank piece
 the    actual    text.   An   appendix   of   paper  -  there  is  no  text  or
 summarizes the commands.                 information  present.  This  must   be
                                          supplied  by  the person using UED; it
      Disclaimer                          is usually done by typing in the text,
                                          or by reading it into UED from a file.
      This is  an  introduction  and  a   We will start by typing in some  text,
 tutorial.  For this reason, no attempt   and  return  shortly  to  how  to read
 is made to cover more than a  part  of   files.
 the   facilities   that   UED   offers
 (although this fraction  includes  the        First a bit  of  terminology.  In
 most   useful   and   frequently  used   UED  jargon,  the text being worked on
 parts).  Also,  there  is  not  enough   is said to  be  "kept  in  a  buffer."
 space to explain basic RSX procedures.   Think  of  the buffer as a work space,
 We  will  assume  that you know how to   if  you  like,  or   simply   as   the
 log on to RSX, and that  you  have  at   information  that  you are going to be
 least  a vague understanding of what a   editing. In effect the buffer is  like
 file is.                                 the  piece  of paper, on which we will
                                          write  things,  then  change  some  of
      You must also know what character   them, and finally file the whole thing
 to type as  the  end-of-line  on  your   away for another day.
 particular   terminal.   This   is   a
 "newline" on Model 37  Teletypes,  and        The  user tells UED what to do to
 "return"  on  most others. Throughout,   his text by typing instructions called
 we  will  refer  to  this   character,   "commands." Most commands consist of a
 whatever it is, as "newline".            single letter, which can be  typed  in
                                          either  case. Each command is typed on
                                          a  separate   line.   (Sometimes   the
                                          command  is  preceded  by  information
                                          about what line or lines of  text  are
 Getting Started                          to  affected  -  we will discuss these
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 2
 
 
 shortly.)  UED  prompts  for  commands
 with a "*."                              Error Messages - "?"
 
                                               If  at any time you make an error
      The   first  command  is  append,   in the commands you type  to  UED,  it
 written as the letter                    will complain.
 
                                               The  messages  may  sometimes  be
      a                                   cryptic, but with  practice,  you  can
                                          usually figure out how you goofed.
 all by itself. It  means  "append  (or
 add)  text  lines  to the buffer, as I   Writing text out as a file - the Write
 type them  in."  Appending  is  rather   command "w"
 like writing fresh material on a piece
 of paper.                                     It's likely that  we'll  want  to
                                          save  our text for later use. To write
      So  to  enter  lines of text into   out the contents of the buffer onto  a
 the  buffer,  we  just  type  an   "a"   file, we use the write command
 followed by a newline, followed by the
 lines of text we want, like this:             w
 
     a                                    followed by the filename  we  want  to
     Now is the time                      write  on. This will copy the buffer's
     for all good men                     contents  onto  the   specified   file
     to come to the aid of their party.   (destroying  any  previous information
     .                                    on the file). To save the  text  on  a
                                          file named "junk", for example, type
      The only way to stop appending is
 to  type  a  line that contains only a        w junk
 period. The "." is used  to  tell  UED
 that we have finished appending. (Even        Leave a space between "w" and the
 experenced     users    forget    that   file   name.   UED   will  respond  by
 terminating  "."  sometimes.  If   UED   printing the number of lines it  wrote
 seems  to  be  ignoring  you,  type an   out.  In  our  case, UED would respond
 extra line with just "."  on  it.  You   with
 may   then   find  you've  added  some
 garbage  lines  to  your  text,  which        3
 you'll have to take out later.)
                                               Writing a file just makes a  copy
                                          of  the  text  - the buffer's contents
                                          are not disturbed, so  we  can  go  on
                                          adding   lines   to  it.  This  is  an
      After the append command has been   important  point.  UED  at  all  times
 done,  the  buffer  will  contain  the   works  on  a  copy  of a file, not the
 three lines                              file itself. No change in the contents
                                          of a file takes place until you give a
     Now is the time                      "w" command.  (Writing  out  the  text
     for all good men                     onto a file from time to time as it is
     to come to the aid of their party.   being created is a good idea!!!! Since
                                          if  the  system crashes or if you make
 The  "a" and "." aren't there, because   some horrible mistake, you  will  lose
 they are not text.                       all  the  text  in  the buffer but any
                                          text that was written onto a  file  is
      To  add  more  text  to  what  we   relatively safe.)
 already have, just issue  another  "a"
 command, and continue typing.            Leaving UED - the Quit command "q"
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 3
 
 
 
      To terminate a session with  UED,   which  is  the  number  of  lines   in
 save  the  text  you're  working on by   "junk". If anything was already in the
 writing it onto a file using  the  "w"   buffer, it is deleted first.
 command, and then type the command
                                               If we use the "e" command to read
      q                                   a  file  into the buffer, then we need
                                          not use a file name after a subsequent
 which stands for quit. The system will   "w" command; UED  remembers  the  last
 respond  with  ">". At this point your   file  name used in an "e" command, and
 buffer vanishes, with  all  its  text,   "w" will write on this  file.  Thus  a
 which  is why you want to write it out   common way to operate is
 before quitting. For  UED,  make  sure
 you study the ^z command.                     UED
                                               e file
                                               [editing session]
 Exercise 1:                                   w
                                               q
      Enter  UED  and  create some text
 using                                         You can find out at any time what
                                          file name UED is remembering by typing
      a                                   the  file command "f". In our case, if
      ....text....                        we typed
      .
                                               f
      Write  it  out  using  "w".  Then   UED would reply
 leave  UED  with  the "q" command, and
 print the file, to see that everything        junk
 worked. (To print a file, say
                                               Reading text from a  file  -  the
      L filename                          Read command "r"
 
                                               Sometimes  we want to read a file
 in response to ">".                      into  the  buffer  without  destroying
                                          anything  that  is already there. This
      Reading text from a  file  -  the   is done by the read command  "r".  The
 Edit command "e"                         command
 
      A common way to get text into the        r junk
 buffer  is  to  read it from a file in
 the file system. This is what  you  do   will  read  the  file  "junk" into the
 to  edit  text that you saved with the   buffer; it  adds  it  to  the  end  of
 "w" command in a previous session. The   whatever  is already in the buffer. So
 edit command "e"  fetches  the  entire   if we do a read after an edit:
 contents of a file into the buffer. So
 if  we have saved the three lines "Now        e junk
 is the time", etc., with a "w" command        r junk
 in an earlier session, the UED command
                                          the buffer will contain two copies  of
      e junk                              the text (six lines).
 
 would fetch the entire contents of the       Now is the time
 file   "junk"  into  the  buffer,  and       for all good men
 respond                                      to come to the aid of their party.
                                              Now is the time
      3                                       for all good men
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 4
 
 
     to come to the aid of their party.
                                               Now is the time
      Like  the  "w"  and "e" commands,        for all good men
 "r" prints the number  of  lines  read
 in,  after  the  reading  operation is        Suppose we want to print all  the
 complete.                                lines  in  the  buffer.  We  could use
                                          "1,3p" as above if we knew there  were
      Generally speaking, "r"  is  much   exactly  3 lines in the buffer. But in
 less used the "e".                       general, we don't know how many  there
                                          are, so what do we use for ending line
 Exercise 2:                              number?   UED   provides  a  shorthand
                                          symbol for "line number of  last  line
      Experiment with the "e" command -   in  buffer" - the dollar sign "$". Use
 try   reading   and  printing  various   it this way:
 files. You may get an error, typically
 because  you  spelled  the  file  name        1,$p
 wrong.  Try  alternately  reading  and
 appending  to  see  that   they   work        This will print all the lines  in
 similarly. Verify that                   the  buffer  (line 1 to last line.) If
                                          you want to stop the  printing  before
      UED filename                        it  is  finished,  hit  a ^o. UED will
                                          wait for the next command.
 is exactly equivalent to
                                               To print the  last  line  of  the
      UED                                 buffer, we could use
      e filename
                                               $,$p
 
 What does                                     but  UED  lets us abbreviate this
                                          to
      f filename
                                               $p
 do?
                                               We can print any single  line  by
      Printing   the  contents  of  the   typing  the  line number followed by a
 buffer - the Print command "p"           "p". Thus
 
      To print or list the contents  of        1p
 the  buffer  (or  parts  of it) on the
 terminal, we use the print command       produces the response
 
      p                                        Now is the time
 
      The  way  this  is  done  is   as   which is the first line of the buffer.
 follows. We specify the lines where we
 want  printing  to  begin and where we        In  fact,  UED lets us abbreviate
 want it to end, separated by a  comma,   even further: we can print any  single
 and  followed  by the letter "p". Thus   line  by typing just the line number -
 to print the first two  lines  of  the   no need to type the letter "p". So  if
 buffer, for example, (that is, lines 1   we say
 through 2) we say
                                               $
      1,2p   (starting  line=1,  ending
              line=2 p)                   UED  will  print  the last line of the
                                          buffer for us.
 UED will respond with
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 5
 
 
      We   can   also   use   "$"    in
 combinations like                             Dot is a line number in the  same
                                          way that "$" is; it means exactly "the
      $-1,$p                              current  line",  or loosely, "the line
                                          we most recently did something to." We
 which prints the last two lines of the   can use  it  in  several  ways  -  one
 buffer. This helps when we want ot see   possibility
 how far we got in typing.
                                               .,$p
 Exercise 3:
                                          This  will  print  all  the lines from
      As before, create some text using   (including) the current  line  to  the
 the append command and experiment with   end  of  the buffer. In our case these
 the the "p" command.  You  will  find,   are lines 3 through 6.
 for example, that you can't print line
 0  or  a  line  beyond  the end of the        Some commands change the value of
 buffer, and that attempts to  print  a   dot, while others do  not.  The  print
 buffer in reverse order by saying        command  sets dot to the number of the
                                          last  line  printed;   by   our   last
      3,1p                                command, we would have "." - "$" - 6.
 
 don't work.                                   Dot  is  most useful when used in
                                          combinations like this one:
 The current line - "Dot" or "."
                                               .+1     (or equivalently, .+1p)
      Suppose our buffer still contains
 the  six  lines as above, that we have   This means "print the next  line"  and
 just typed                               gives  us  a  handy way to step slowly
                                          through a buffer. We can also say
      1,3p
                                               .-1     (or .-1p)
 and UED has printed  the  three  lines
 for us. Try typing just                  which means "print the line before the
                                          current line." This enables us  to  go
      p     (no line numbers).            backwards  if  we wish. Another useful
                                          one is something like
 This will print
                                               .-3,.-1p
     to come to the aid of their party.
                                          which prints the previous three lines.
 which is the third line of the buffer.
 In  fact  it is the last (most recent)        Don't forget that  all  of  these
 line that we have done anything  with.   change  the value of dot. You can find
 (We  just  printed  it!) We can repeat   out what dot is at any time by typing
 this "p" command without line numbers,
 and it will continue to print line 3.         .=
 
      The reason is that UED  maintains   UED will respond by printing the value
 a  record of the last line that we did   of dot.
 anything to (in  this  case,  line  3,
 which  we just printed) so that it can        Let's summarize some things about
 be used instead of  an  explicit  line   the "p" command and  dot.  Essentially
 number.   This  most  recent  line  is   "p" can be preceded by 0, 1, or 2 line
 referred to by the shorthand symbol      numbers.  If  there  is no line number
                                          given, it prints the  "current  line",
         .      (pronounced "dot").       the  line that dot refers to. If there
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 6
 
 
 is one  line  number  given  (with  or
 without the letter"p"), it prints that        If you are adventurous, try using
 line  (and  sets  dot to the last line   line numbers with "a", "r", and "w" as
 printed.)  If  two  line  numbers  are   well. You  will  find  that  "a"  will
 specified  the  first  can"t be bigger   append  lines  after  the  line number
 than the second (see                     that you specify  (rather  than  after
                                          dot);  that  "r" reads a file in after
 Exercise 2.                              the  line  number  you  specify   (not
                                          necessarily at the end of the buffer);
      Typing  a  signle  newline   will   and  that  "w"  will write out exactly
 cause printing of the next line - it's   the lines you specify, not necessarily
 equivalent to ".+p". Try it. Try using   the whole buffer. These variations are
 "ESCAPE"  key  -  it"s  equivalent  to   sometimes handy. For instance you  can
 ".-1p".                                  insert  a  file  at the beginning of a
                                          buffer by saying
 Deleting lines: the "d" command
                                               0r filename
      Suppose we want to get rid of the
 three extra lines in the buffer.  This   and  you  can  enter  lines   at   the
 is done by the delete command            beginning of the buffer by saying
 
      d                                        0a
                                               ...text...
      Except  that  "d"  deletes  lines        .
 instead of printing them,  its  action
 is  similar  to that of "p". The lines   Notice  that  ".w"  is  very different
 to be deleted are  specified  for  "d"   from
 exactly as they are for "p":
                                               .
      starting line, ending line d             w
 
 Thus the command                         Modifying text: the Substitute command
                                          "s"
      4,$d
                                               We are now ready to  try  one  of
 deletes lines 4 through the end. There   the  most  important of all commands -
 are  now  three  lines left, as we can   the substitute command
 check by using
                                               s
      1,$p
                                          This is the command that  is  used  to
 And notice that "$" now is line 3! Dot   change  individual  words  or  letters
 is set to the next line after the last   within a line or group of lines. It is
 line  deleted,  unless  the  last line   what  we   use,   for   example,   for
 deleted  is  the  last  line  in   the   correcting   spelling   mistakes   and
 buffer.  In  that  case, dot is set to   typing errors.
 "$".
                                          Suppose that by a typing error, line 1
 Exercise 4:                              says
 
      Experiment with  "a",  "e",  "r",        Now is th time
 "w",  "p",  and "d" until you are sure
 that you know what they do, and  until   the "e" has been left  off  "the".  We
 you  understand how dot, "$", and line   can use "s" to fix this up as follows:
 numbers are used.
                                               1s/th/the/
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 7
 
 
 
 This  says: "in line 1, substitute for        s/something/something else/p
 the  characters  'th'  the  characters
 'the'."  To  verify that it works (UED   which  makes  some  correction  on the
 will    not    print    the     result   current line, and then prints  it,  to
 automatically) we say                    make  sure  it worked out right. If it
                                          didn't, we can try again. (Notice that
      p                                   we put a print  command  on  the  same
                                          line   as  the  substitute.  With  few
 and get                                  exceptions,   "p"   can   follow   any
                                          command;  no other multi-command lines
      Now is the time                     are legal.)
 
 which  is  what we wanted. Notice that        It's also legal to say
 dot must have been  set  to  the  line
 where  the  substitution  took  place,        s/...//
 since the  "p"  command  printed  that
 line.  Dot is always set this way with   which means "change the  first  string
 the "s" command.                         of   characters   to  nothing",  i.e.,
                                          remove  them.  This  is   useful   for
 The general way to use the  substitute   deleting  extra  words  in  a  line or
 command is                               removing extra letters from words. For
                                          instance, if we had
 starting,ending s/change this/to this/
                                               Nowxx is the time
      Whatever  string of characters is
 between the first pair of  slashes  is   we can say
 replaced  by  whatever  is between the
 second pair, in all the lines  between        s/xx//p
 starting  line  and  ending line. Only
 the first occurrence on each  line  is   to get
 changed,   however.  If  you  want  to
 change every occurrence, see  Exercise        Now is the time
 5.  The rules for line numbers are the
 same as those for "p" except that  dot   Notice  that  "//"  here   means   "no
 is  set to the last line changed. (But   characters",  not  a blank. There is a
 there is a trap for the unwary: if  no   difference!  (See  below  for  another
 substitution  took  place,  dot is not   meaning of "//".)
 changed. This causes and  error  as  a
 warning.)                                Exercise 5:
 
      Thus we can say                          Experiment  with  the  substitute
                                          command.  See  what  happens  if   you
      1,$s/speling/spelling/              substitute  for  some  word  on a line
                                          with several occurrences of that word.
 and correct the first spelling mistake   For example, do this:
 on  each  line  in  the text. (This is
 useful for people who  are  consistent        a
 misspellers!)                                 the other side of the coin
                                               .
      If no line numbers are given, the        s/the/on the/p
 "s"  command assumes we mean "make the
 substitution  on  line  dot",  so   it   You will get
 changes  things  only  on  the current
 line. This leads to  the  very  common        on the other side of the coin
 sequence.
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 8
 
 
 A substitute command changes only  the   /string of characters we want to find/
 first  occurrence of the first string.
 You  can  change  all  occurrences  by   For example, the UED line
 adding a "g" (for "global") to the "s"
 command, like this:                           /their/
 
      s/.../.../gp                        is   a   context   search   which   is
                                          sufficient to find the diesired line -
 Try   other   characters   instead  of   it will locate the next occurrence  of
 slashes to delimit  the  two  sets  of   the    characters    between   slashes
 characters   in   the  "s"  command  -   ("their"). It also sets  dot  to  that
 anything should work except blanks  or   line   and   prints   the   line   for
 tabs.                                    verification:
 
      (If  you  get funny results using       to come to the aid of their party.
 any of the characters
                                          "Next  occurrence"  means   that   UED
      ^ . $ [ * \                         starts  looking for the string at line
                                          ".+1", searches  to  the  end  of  the
 read    the    section   on   "Special   buffer,  then  continues at line 1 and
 Characters".)                            searches to line dot.  (That  is,  the
                                          search  "wraps around" from "$" to 1.)
 Context searching - "/.../"              It scans all the lines in  the  buffer
                                          until it either finds the desired line
      With   the   substitute   command   or  gets  back  to  dot  again. If the
 mastered,  we  can  move on to another   given string of  characters  can't  be
 highly important idea of UED - context   found in any line, UED types the error
 searching.                               message
 
      Suppose  we  have  our   original         search failure
 three line text in the buffer:
                                          Otherwise it prints the line it found.
     Now is the time
     for all good men                     We  can  do  both  the  search for the
     to come to the aid of their party.   desired line and a substitution all at
                                          once, like this:
      Suppose  we want to find the line
 that contains "their" so we can change        /their/s/their/the/p
 it to "the". Now with only three lines
 in the buffer,  it's  pretty  easy  to   which will yield
 keep  track  of  what  line  the  word
 "their"  is  on.  But  if  the  buffer        to come to the aid of the party.
 contained  serveral hundred lines, and
 we'd been making changes, deleting and        There were three  parts  to  that
 rearranging lines, and so on, we would   last  command:  context search for the
 no longer really know what  this  line   desired line, make  the  substitution,
 number  would be. Context searching is   print the line.
 simply  a  mothod  of  specifying  the
 desired  line,  regardless of what its        The  expression  "/their/"  is  a
 number is, by specifying some  context   context search  expression.  In  their
 on it.                                   simplest   form,  all  context  search
                                          expressions are like this -  a  string
      The way we say "search for a line   of  characters  surrounded by slashes.
 that  contains  this particular string   Context searches  are  interchangeable
 of characters" is to type                with  line  numbers,  so  ;they can be
                                          used by themselves to find and print a
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 9
 
 
 desired line, or as line  numbers  for   line   number,   so  it  can  be  used
 some  other command, like "s". We used   wherever a line number is needed.
 them both ways in the examples above.
                                          Exercise 6:
      Suppose the buffer  contains  the
 three familiar lines                          Experiment      with      context
                                          searching.  Try  a  body  of text with
     Now is the time                      several occurrences of the same string
     for all good men                     of characters,  and  scan  through  it
     to come to the aid of their party.   using the same context search.
 
 Then the UED line numbers                     Try  using  context  searches  as
                                          line numbers for the substitute, print
      /Now/+1                             and delete commands. (They can also be
      /good/                              used with "r", "w", and "a".)
      /party/-1
                                               Try   context   searching   using
 are  all  context  search expressions,   "?text?"  instead  of  "/text/".  This
 and they all refer to  the  same  line   scans lines in the buffer  in  reverse
 (line  2). To make a change in line 2,   order  rather  than  normal.  This  is
 we could say                             sometimes useful if  you  go  too  far
                                          while   looking  for  some  string  of
      /Now/+1s/good/bad/                  characters - it's an easy way to  back
                                          up.
 or
                                               (If  you  get  funny results with
      /good/s/good/bad/                   any of the characters
 
 or                                            $ [ * \
 
      /party/-1s/good/bad/                     read  the  section  on   "Special
                                          Characters".)
 The  choice  is   dictated   only   by
 convenience.  We could print all three        UED   provides  a  shorthand  for
 lines by, for instance                   repeating a  context  search  for  the
                                          same string. For example,
      /Now/,/party/p
                                               /string/
 or
                                          will  find  the  next  occurrence   of
      /Now/,/Now/+2p                      "string".  It  often happens that this
                                          is not the desired line, so the search
 or    by   any   number   of   similar   must be repeated. This can be done  by
 combinations. The first one  of  these   typing merely
 might  be  better if we don't know how
 many lines are involved.  (Of  course,        //
 if  there were only three lines in the
 buffer, we'd use                         This  shorthand  stands  for "the most
                                          recently    used    context     search
      1,$p                                expression."  It  can  also be used as
                                          the first  string  of  the  substitute
 but  not   if   there   were   several   command, as in
 hundred.)
                                               /string1/s//string2/
      The  basic  rule  is:  a  context
 search expression is  the  same  as  a   which will find the next occurrence of
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 10
 
 
 "string1" and replace it by "string2".   "Insert" is similar to  append  -  for
 This   can   save  a  lot  of  typing.   instance
 Similarly
                                               /string/i
      ??                                  ...type the lines to be inserted here.
 
 means "scan  backwards  for  the  same   will  insert the given text before the
 expression."                             next line that contains "string".  The
                                          text  between  "i" and "." is inserted
 Change and Insert - "c" and "i"          before the specified line. If no  line
                                          number  is  specified dot is used. Dot
 This   section  discusses  the  change   is set to the last line inserted.
 command
                                          Exercise 7:
      c
                                               "Change"   is   rather   like   a
 which  is  used to change or replace a   combination   of  delete  followed  by
 group of one or more  lines,  and  the   insert. Experiment to verify that
 insert command
                                               start, end d
      i                                        i
                                               ...text...
 which is used for inserting a group of        .
 one or more lines.
                                          is almost the same as
      "Change", written as
                                               start, end c
      c                                        ...text...
                                               .
 is  used  to replace a number of lines
 with different lines, which are  typed   Experiment to verify that
 in  at  the  terminal. For example, to
 change  lines  ".+1"  through  "$"  to        start, end d
 something else, type                          i
                                               ...text...
      .+1,$c                                   .
      ...type the text you want here...
                                          is almost the same as
      The  lines  you  type between the
 "c" command and the "." will take  the        start, end c
 place  of  the  original lines between        ...text...
 start line and end line. This is  most        .
 useful  in replacing a line or several
 lines which have errors in them.         These are not precisely  the  same  if
                                          line "$" gets deleted. Check this out.
      If only one line is specified  in   out. What is dot?
 the  "c"  command, then just that line
 is replaced. (You can type in as  many        Experiment  with  "a" and "i", to
 replacement lines as you like.) Notice   see that they are similar, but not the
 the use of "." to end the input - this   same. You will observe that
 works  just like the "." in the append
 command and must appear by itself on a        line-number a
 new line. If no line number is  given,        ...text...
 line dot is replaced. The value of dot        .
 is set to the last line you typed in.
                                          appends after the given line, while
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 11
 
 
                                          The global commands "g" and "y"
      line-number i
      ...text...                               The global command "g" is used to
      .                                   execute  one  or  more UED commands on
                                          all those lines  in  the  buffer  that
 inserts  before it. Observe that if no   match   some   specified  string.  For
 line  number  is  given,  "i"  inserts   example
 before   line  dot,  while  "a"appends
 after line dot.                               g/peling/p
 
                                          prints   all   lines   that    contain
 Moving text around: the "m" command      "peling". More usefully,
 
      The move command "m" is used  for        g/peling/s//pelling/gp
 cutting and pasting - it lets you move
 a  group  of  lines  from one place to   makes  the  substitution everywhere on
 another in the buffer. Suppose we want   the line, then prints  each  corrected
 to put the first three  lines  of  the   line. Compare this to
 buffer at the end instead. We could do
 it by saying:
                                               1,$s/peling/pelling/gp
      1,3w temp
      $r temp                             which   only   prints  the  last  line
      1,3d                                substituted. Another subtle difference
                                          is that the "g" command does not  give
 (Do  you  see why?) but we can do it a   a  "?"  if "peling" is not found where
 lot easier with the "m" command:         the "s" command will.
 
      1,3m$                                    There  may  be  several  commands
                                          (including  "a",  "c",  "i", "r", "w",
 The general case is                      but not "g"); in that case, every line
                                          except  the  last  must  end  with   a
      start line, end line m after this   backslash "\":
 
 Notice  that  there is a third line to        g/xxx/.-1s/abc/def^
 be specified -  the  place  where  the        .+2s/ghi/jkl^
 moved  stuff  gets  put. Of course the        .-2,.p
 lines to be moved can be specified  by
 context searches; if we had              makes  changes in the lines before and
                                          after each line that  contains  "xxx",
      First paragraph                     then prints all three lines.
      ...
      end of first paragraph.                  The  "v"  command  is the same as
      Second paragraph                    "g",  except  that  the  commands  are
      ...                                 excuted  on  every  line that does not
      end of second paragraph.            match the string following "v"
 
      we    could   reverse   the   two        v/ /d
 paragraphs like this:
                                          deletes   every  line  that  does  not
      /Second/,/second/m/First/-1         contain a blank.
 
 Notice the "-1" - the moved text  goes   Special Characters
 after the line mentioned. Dot gets set
 to the last line moved.                       You may have noticed that  things
                                          just  don"t  work  right when you used
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 12
 
 
 some characters like  ".",  "*",  "$",   will  only  find  an   occurrence   of
 and others in context searches and the   "string"  that  is  at the end of some
 substitute   command.  The  reason  is   line. This implies, of course, that
 rather complex, although the  cure  is
 simple.  Basically,  UED  treats these        /^string$/
 characters as  special,  with  special
 meanings.  For  instance, in a context   will  find  only  a line that contains
 search or  the  first  string  of  the   just "string", and
 substitute command only,
                                               /^.$/
      /x.y/
                                          finds a line  containing  exaclly  one
      means  "a  line  with  an  x, any   character.
 character, and a y," not just "a  line
 with  an  x,  a  period,  and  a y." A   The  character  ".",  as  we mentioned
 complete   list   of    the    special   above, matches anything:
 characters  that  can cause trouble is
 the following:                                /x.y/
 
      ^ . $ [ * \                         matches any of
 
 Warning:  The backslash character \ is        x+y
 special to  UED.  For  safety's  sake,        x-y
 avoid  it  where possible. If you have        x y
 to use one of the  special  characters        x.y
 in  a substitute command, you can turn
 off its magic meaning  temporarily  by   This is  useful  in  conjunction  with
 preceding it with the backslash. Thus    "*",  which is a repetition character;
                                          "a*" is a shorthand for "any number of
      s/\\\.\*/backslash dot star/        a's," so ".*" matches  any  number  of
                                          anythings. This is used like this:
 will  change "\.*" into "backslash dot
 star".                                        s/./stuff/
 
      Here is a hurried synopsis of the   which changes an entire line; or
 other special characters.  First,  the
 circumflex "^" signifies the beginning        s/.*,//
 of a line. Thus
                                          which  deletes  all  characters in the
      /^string/                           line up  to  and  including  the  last
                                          comma.  (Since  ".*" finds the longest
 finds  "string"  only  if it is at the   possible match, this goes  up  to  the
 beginning of a line: it will find        last comma.)
 
      string                              "["   is   used   with   "]"  to  form
                                          "character classes"; for example.
 but not
                                               /[1234567890]/
      the string...
                                          matches any single digit - any one  of
 The  dollar-sign  "$"  is   just   the   the  characters inside the braces will
 opposite  of  the circumflex; it means   cause a match.
 the end of a line;
                                               Finaly,  the   "&"   is   another
      /string$/                           shorthand  character - it is used only
                                          on the right-hand part of a substitute
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 13
 
 
 command where it means  "whatever  was   meaning elsewhere. We can turn off the
 matched  on the left-hand side". It is   special meaning of "&" by preceding it
 used  to  save  typing.  Suppose   the   with a "\":
 current line contained
                                               s/ampersand/\&/
      Now is the time
                                          will convert the word "ampersand" into
 and   we  wanted  to  put  parentheses   the  literal symbol "&" in the current
 around it. We could  just  retype  the   line.
 line, but this is tedious. Or we could
 say
 
      s/^/(/                              Summary of Commands and Line Numbers
      s/$/)/
                                          The  general  form  of UED commands is
 using  our  knowledge  of "^" and "$".   the command name, perhaps preceded  by
 But the easiest way uses the "&":        one  or  two line numbers, and, in the
                                          case of e, r and w, followed by a file
      s/./(&)/                            name. Only one command is allowed  per
                                          line,  but  a p command may follow any
 This says "match the whole  line,  and   other command (except for e, r, w  and
 replace  it  by  itself  surrounded by   q).
 parens." The "&" can be  used  several
 times in a line; consider using          a (append) Add lines to the buffer (at
                                          line  dot,  unless  different  line is
      s/.*/&? &!!/                        specified). Appending continues  until
                                          "." is typed on a new line. Dot is set
 to produce                               to the last line appended.
 
     Now is the time? Now is the time!!   c  (change) Change the specified lines
                                          to the new text which follows. The new
      We  don't have to match the whole   lines are terminated by a ".".  If  no
 line,  of  course:   if   the   buffer   lines are specified, replace line dot.
 contains                                 Dot is set to last line changed.
 
      the end of the world                d (delete) Delete the lines specified.
                                          If  none  are  specified,  delete line
 we could type                            dot. Dot is set to the first undeleted
                                          line, unless "$" is deleted, in  which
      /world/s//& is at hand/             case dot is set to "$".
 
 to produce                               e  (edit)  Edit new file. Any previous
                                          contents  of  the  buffer  are  thrown
      the end of the world is at hand     away,  so issue a w before-hand if you
                                          want to save them.
 Observe this expression carefully, for
 it illustrates how to  take  advantage   f (file) Print remembered filename. If
 of  UED  to  save  typing.  The string   a name follows f the  remembered  name
 "/world/" found the desired line;  the   will be set to it.
 shorthand  "//" found the same word in
 the line; and the "&"  saved  us  from   g (global) g/---/commands will execute
 typing it again.                         the   commands  on  those  lines  that
                                          contain  "---",  which  can   be   any
      The "&" is  a  special  character   context search expression.
 only  within the replacement text of a
 substitute command, and has no special   i   (insert)   Insert   lines   before
 
 
 
 
 
 
 
                              19-Sep-80 5:42:29 Ued Page 14
 
 
 specified line (or dot) until a "." is   around to "$".
 typed on a new line.  Dot  is  set  to
 last line inserted.
 
 m (move) Move lines specified to after
 the  line named after m. Dot is set to
 the last line moved.
 
 p (print) Print  specified  lines.  If
 none  specified,  print  line  dot.  A
 single line number  is  equivalent  to
 "line-number   p".  A  single  newline
 prints ".+1", the next line.
 
 q (quit) Exit from UED. Wipes out  all
 text in buffer!!
 
 r  (read)  Read a file into buffer (at
 end unless specified  elsewhere.)  Dot
 set to last line read.
 
 s (substitute) s/strint1/string2/ will
 substitute the characters of 'string2'
 for  'string1'  in specified lines. If
 no    line    is    specified,    make
 substitution  in  line dot. Dot is set
 to last line in which  a  substitution
 took  place,  dot  is  not  changed. s
 changes only the first  occurrence  of
 string1  on  a  line; to change all of
 them,  type  a  "g"  after  the  final
 slash.
 
 v  (exclude)  v/---/commands  executes
 "commands" on those lines that do  not
 contain "---".
 
 w  (write)  Write  out  buffer  onto a
 file. Dot is not changed.
 
 .= (dot value)  Print  value  of  dot.
 ("="  by  itself  prints  the value of
 "$".)
 
 ! (temporary escape)
 Execute this line as a system command.
 
 /------/ Context  search.  Search  for
 next  line  which contains this string
 of characters. Print it. Dot is set to
 line where string found. Search starts
 at ".+1", wraps around from "$" to  1,
 and continues to dot, if necessary.
 
 ?------?  Context  search  in  reverse
 direction. Start search at ".-1", wrap
 
 
 
 
 
