home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ed-0.2-bin.lha / info / ed.info (.txt)
GNU Info File  |  1996-10-12  |  29KB  |  574 lines

  1. This is Info file ed.info, produced by Makeinfo-1.64 from the input
  2. file ed.texinfo.
  3.    This file documents the `ed' command, which has the purpose of
  4. editing text files.
  5.    Copyright (C) 1993 by the Free Software Foundation, Inc.
  6.    Permission is granted to make and distribute verbatim copies of this
  7. manual provided the copyright notice and this permission notice are
  8. preserved on all copies.
  9.    Permission is granted to copy and distribute modified versions of
  10. this manual under the conditions for verbatim copying, provided that
  11. the entire resulting derived work is distributed under the terms of a
  12. permission notice identical to this one.
  13.    Permission is granted to copy and distribute translations of this
  14. manual into another language, under the above conditions for modified
  15. versions, except that this permission notice may be stated in a
  16. translation approved by the Foundation.
  17. File: ed.info,  Node: Top,  Next: Intro,  Prev: (dir),  Up: (dir)
  18.    This info file documents the `ed' text editor, as of release 0.2.
  19. You may find in this document:
  20. * Menu:
  21. * Intro::                       An introduction to line editing with  `ed'
  22. * Invoking ed::                 GNU `ed' command-line options
  23. * Line addressing::             Specifying lines/ranges in the buffer
  24. * Regular expressions::         Patterns for selecting text
  25. * Commands::                    Commands recognized by GNU `ed'
  26. * Limitations::                 Intrinsic limits of GNU `ed'
  27. * Diagnostics::                 GNU `ed' error handling
  28. File: ed.info,  Node: Intro,  Next: Invoking ed,  Prev: Top,  Up: Top
  29. Intro
  30. *****
  31.    `ed' is a line-oriented text editor.  It is used to create, display,
  32. modify and otherwise manipulate text files, both interactively and via
  33. shell scripts.  A restricted version of `ed', `red', can only edit
  34. files in the current directory and cannot execute shell commands.  `ed'
  35. is the "standard" text editor in the sense that it is the original
  36. editor for Unix, and thus widely available.  For most purposes,
  37. however, it is superceded by full-screen editors such as Emacs and Vi.
  38.    The sample sessions below illustrate some basic concepts of line
  39. editing with `ed'.  We begin by creating a file, `sonnet', with some
  40. help from Shakespeare.  As with the shell, all input to `ed' must be
  41. followed by a newline character.  Comments begin with a `#'.
  42.      $ ed
  43.      # The `a' command is for appending text to the editor buffer.
  44.      a
  45.      No more be grieved at that which thou hast done.
  46.      Roses have thorns, and filvers foutians mud.
  47.      Clouds and eclipses stain both moon and sun,
  48.      And loathsome canker lives in sweetest bud.
  49.      .
  50.      # Entering a single period on a line returns `ed' to command mode.
  51.      # Now write the buffer to the file `sonnet' and quit:
  52.      w sonnet
  53.      183
  54.      # `ed' reports the number of characters written.
  55.      q
  56.      $ ls -l
  57.      total 2
  58.      -rw-rw-r--    1 alm           183 Nov 10 01:16 sonnet
  59.      $
  60.    Editing with `ed' is done in two distinct modes: "command" and
  61. "input".  When first invoked, `ed' is in command mode.  In this mode
  62. commands are read from the standard input and executed to manipulate
  63. the contents of the editor buffer.  When an input command, such as `a'
  64. (append), `i' (insert) or `c' (change), is given, `ed' enters input
  65. mode.  This is the primary means of adding text to a file.  In this
  66. mode, no commands are available; instead, the standard input is written
  67. directly to the editor buffer. A "line" consists of the text up to and
  68. including a newline character.  Input mode is terminated by entering a
  69. single period (`.') on a line.
  70.    In the next example, some typos are corrected in the file `sonnet'.
  71.      $ ed sonnet
  72.      183
  73.      # Begin by printing the buffer to the terminal with the `p' command.
  74.      # The `,' means ``all lines.''
  75.      ,p
  76.      No more be grieved at that which thou hast done.
  77.      Roses have thorns, and filvers foutians mud.
  78.      Clouds and eclipses stain both moon and sun,
  79.      And loathsome canker lives in sweetest bud.
  80.      # Select line 2 for editing.
  81.      2
  82.      Roses have thorns, and filvers foutians mud.
  83.      # Use the substitute command, `s', to replace `filvers' with `silver',
  84.      # and print the result.
  85.      s/filvers/silver/p
  86.      Roses have thorns, and silver foutians mud.
  87.      # And correct the spelling of `fountains'.
  88.      s/utia/untai/p
  89.      Roses have thorns, and silver fountains mud.
  90.      w sonnet
  91.      183
  92.      q
  93.      $
  94.    `ed' may be invoked with or without arguments *Note Invoking ed::.
  95. When invoked with a FILE argument, a copy of FILE is read into the
  96. editor's buffer.  Changes are made to this copy and not directly to
  97. FILE itself.  Upon quitting `ed', any changes not explicitly saved with
  98. a `w' command *Note Commands::, are lost.
  99.    Since `ed' is line-oriented, we have to tell it which line, or range
  100. of lines we want to edit.  In the above example, we do this by
  101. specifying the line's number, or sequence in the buffer.  Alternatively,
  102. we could have specified a unique string in the line, e.g., `/filvers/',
  103. where the `/'s delimit the string in question.  Subsequent commands
  104. affect only the selected line, a.k.a. the "current" line.  Portions of
  105. that line are then replaced with the substitute command, whose syntax is
  106. `s/OLD/NEW/'.
  107.    Although `ed' accepts only one command per line, the print command
  108. `p' is an exception, and may be appended to the end of most commands.
  109.    In the next example, a title is added to our sonnet.
  110.      $ ed sonnet
  111.      183
  112.      a
  113.       Sonnet #50
  114.      .
  115.      ,p
  116.      No more be grieved at that which thou hast done.
  117.      Roses have thorns, and silver fountains mud.
  118.      Clouds and eclipses stain both moon and sun,
  119.      And loathsome canker lives in sweetest bud.
  120.       Sonnet #50
  121.      # The title got appended to the end; we should have used `0a'
  122.      # to append ``before the first line.''
  123.      # Move the title to its proper place.
  124.      5m0p
  125.       Sonnet #50
  126.      # The title is now the first line, and the current line has been
  127.      # set to this line as well.
  128.      ,p
  129.       Sonnet #50
  130.      No more be grieved at that which thou hast done.
  131.      Roses have thorns, and silver fountains mud.
  132.      Clouds and eclipses stain both moon and sun,
  133.      And loathsome canker lives in sweetest bud.
  134.      wq sonnet
  135.      195
  136.      $
  137.    When `ed' opens a file, the current line is initially set to the last
  138. line of that file.   Similarly, the move command `m' sets the current
  139. line to the last line moved.
  140.    In summary: All `ed' commands operate on whole lines or ranges of
  141. lines; e.g., the `d' command deletes lines; the `m' command moves
  142. lines, and so on.  It is possible to modify only a portion of a line by
  143. means of replacement, as in the second example above.  However even
  144. there, the `s' command is applied to whole lines at a time.
  145.    Structurally, `ed' commands consist of zero or more line addresses,
  146. followed by a single character command and possibly additional
  147. parameters; i.e., commands have the structure:
  148.      [ADDRESS [,ADDRESS]]COMMAND[PARAMETERS]
  149.    The ADDRESS(es) indicate the line or range of lines to be affected
  150. by the command.  If fewer addresses are given than the command accepts,
  151. then default addresses are supplied.
  152.    Related programs or routines are `vi (1)', `sed (1)', `regex (3)',
  153. `sh (1)'.  Relevant documents are:
  154.      Unix User's Manual Supplementary Documents: 12 -- 13
  155.      B. W. Kernighan and P. J. Plauger: "Software Tools in Pascal",
  156.      Addison-Wesley, 1981.
  157. File: ed.info,  Node: Invoking ed,  Next: Line addressing,  Prev: Intro,  Up: Top
  158. Invoking GNU `ed'
  159. *****************
  160.      ed [-] [-Gs] [-p STRING] [FILE]
  161.      red [-] [-Gs] [-p STRING] [FILE]
  162.      Forces backwards compatibility.  This affects the behavior of the
  163.      `ed' commands `G', `V', `f', `l', `m', `t' and `!!'.  If the
  164.      default behavior of these commands does not seem familiar, then
  165.      try invoking `ed' with this switch.
  166.      Suppresses diagnostics. This should be used if `ed''s standard
  167.      input is from a script.
  168. `-p STRING'
  169.      Specifies a command prompt.  This may be toggled on and off with
  170.      the `P' command.
  171.    FILE specifies the name of a file to read.  If FILE is prefixed with
  172. a bang (!), then it is interpreted as a shell command.  In this case,
  173. what is read is the standard output of FILE executed via `sh (1)'.  To
  174. read a file whose name begins with a bang, prefix the name with a
  175. backslash (`\').  The default filename is set to FILE only if it is not
  176. prefixed with a bang.
  177. File: ed.info,  Node: Line addressing,  Next: Regular expressions,  Prev: Invoking ed,  Up: Top
  178. Line addressing
  179. ***************
  180.    An address represents the number of a line in the buffer.  `ed'
  181. maintains a "current address" which is typically supplied to commands
  182. as the default address when none is specified.  When a file is first
  183. read, the current address is set to the last line of the file.  In
  184. general, the current address is set to the last line affected by a
  185. command.
  186.    A line address is constructed from one of the bases in the list
  187. below, optionally followed by a numeric offset.  The offset may include
  188. any combination of digits, operators (i.e., `+', `-' and `^') and
  189. whitespace.  Addresses are read from left to right, and their values
  190. are computed relative to the current address.
  191.    One exception to the rule that addresses represent line numbers is
  192. the address `0' (zero).  This means "before the first line," and is
  193. legal wherever it makes sense.
  194.    An address range is two addresses separated either by a comma or
  195. semicolon. The value of the first address in a range cannot exceed the
  196. value of the the second.  If only one address is given in a range, then
  197. the second address is set to the given address.  If an N-tuple of
  198. addresses is given where N > 2, then the corresponding range is
  199. determined by the last two addresses in the N-tuple.  If only one
  200. address is expected, then the last address is used.
  201.    Each address in a comma-delimited range is interpreted relative to
  202. the current address.  In a semicolon-delimited range, the first address
  203. is used to set the current address, and the second address is
  204. interpreted relative to the first.
  205.    The following address symbols are recognized.
  206.      The current line (address) in the buffer.
  207.      The last line in the buffer.
  208.      The Nth, line in the buffer where N is a number in the range `0,$'.
  209.      The previous line.  This is equivalent to `-1' and may be repeated
  210.      with cumulative effect.
  211.      The Nth previous line, where N is a non-negative number.
  212.      The next line.  This is equivalent to `+1' and may be repeated with
  213.      cumulative effect.
  214. `WHITESPACE N'
  215.      The Nth next line, where N is a non-negative number.  Whitespace
  216.      followed by a number N is interpreted as `+N'.
  217.      The first through last lines in the buffer.  This is equivalent to
  218.      the address range `1,$'.
  219.      The current through last lines in the buffer.  This is equivalent
  220.      to the address range `.,$'.
  221. `/RE/'
  222.      The next line containing the regular expression RE.  The search
  223.      wraps to the beginning of the buffer and continues down to the
  224.      current line, if necessary.  `//' repeats the last search.
  225. `?RE?'
  226.      The previous line containing the regular expression RE.  The
  227.      search wraps to the end of the buffer and continues up to the
  228.      current line, if necessary.  `??' repeats the last search.
  229. `'LC'
  230.      The line previously marked by a `k' (mark) command, where LC is a
  231.      lower case letter.
  232. File: ed.info,  Node: Regular expressions,  Next: Commands,  Prev: Line addressing,  Up: Top
  233. Regular expressions
  234. *******************
  235.    Regular expressions are patterns used in selecting text.  For
  236. example, the `ed' command
  237.      g/STRING/
  238. prints all lines containing STRING.  Regular expressions are also used
  239. by the `s' command for selecting old text to be replaced with new.
  240.    In addition to a specifying string literals, regular expressions can
  241. represent classes of strings.  Strings thus represented are said to be
  242. matched by the corresponding regular expression.  If it is possible for
  243. a regular expression to match several strings in a line, then the
  244. left-most longest match is the one selected.
  245.    The following symbols are used in constructing regular expressions:
  246.      Any character C not listed below, including `{', `}', `(', `)',
  247.      `<' and `>', matches itself.
  248.      Any backslash-escaped character C, other than `{', ``}', `(', `)',
  249.      `<', `>', `b', `B', `w', `W', `+' and `?', matches itself.
  250.      Matches any single character.
  251. `[CHAR-CLASS]'
  252.      Matches any single character in CHAR-CLASS.  To include a `]' in
  253.      CHAR-CLASS, it must be the first character.  A range of characters
  254.      may be specified by separating the end characters of the range
  255.      with a `-', e.g., `a-z' specifies the lower case characters.  The
  256.      following literal expressions can also be used in CHAR-CLASS to
  257.      specify sets of characters:
  258.           [:alnum:] [:cntrl:] [:lower:] [:space:]
  259.           [:alpha:] [:digit:] [:print:] [:upper:]
  260.           [:blank:] [:graph:] [:punct:] [:xdigit:]
  261.      If `-' appears as the first or last character of CHAR-CLASS, then
  262.      it matches itself.  All other characters in CHAR-CLASS match
  263.      themselves.
  264.      Patterns in CHAR-CLASS of the form:
  265.           [.COL-ELM.]
  266.           [=COL-ELM=]
  267.      where COL-ELM is a "collating element" are interpreted according
  268.      to `locale (5)' (not currently supported).  See `regex (3)' for an
  269.      explanation of these constructs.
  270. `[^CHAR-CLASS]'
  271.      Matches any single character, other than newline, not in
  272.      CHAR-CLASS.  CHAR-CLASS is defined as above.
  273.      If `^' is the first character of a regular expression, then it
  274.      anchors the regular expression to the beginning of a line.
  275.      Otherwise, it matches itself.
  276.      If `$' is the last character of a regular expression, it anchors
  277.      the regular expression to the end of a line.  Otherwise, it matches
  278.      itself.
  279. `\(RE\)'
  280.      Defines a (possibly null) subexpression RE.  Subexpressions may be
  281.      nested.  A subsequent backreference of the form `\N', where N is a
  282.      number in the range [1,9], expands to the text matched by the Nth
  283.      subexpression. For example, the regular expression `\(a.c\)\1'
  284.      matches the string `abcabc', but not `abcadc'.  Subexpressions are
  285.      ordered relative to their left delimiter.
  286.      Matches the single character regular expression or subexpression
  287.      immediately preceding it zero or more times.  If `*' is the first
  288.      character of a regular expression or subexpression, then it matches
  289.      itself.  The `*' operator sometimes yields unexpected results.  For
  290.      example, the regular expression `b*' matches the beginning of the
  291.      string `abbb', as opposed to the substring `bbb', since a null
  292.      match is the only left-most match.
  293. `\{N,M\}'
  294. `\{N,\}'
  295. `\{N\}'
  296.      Matches the single character regular expression or subexpression
  297.      immediately preceding it at least N and at most M times.  If M is
  298.      omitted, then it matches at least N times.  If the comma is also
  299.      omitted, then it matches exactly N times.  If any of these forms
  300.      occurs first in a regular expression or subexpression, then it is
  301.      interpreted literally (i.e., the regular expression `\{2\}'
  302.      matches the string `{2}', and so on).
  303.      Anchors the single character regular expression or subexpression
  304.      immediately following it to the beginning (in the case of `\<') or
  305.      ending (in the case of `\>') of a "word", i.e., in ASCII, a
  306.      maximal string of alphanumeric characters, including the
  307.      underscore (_).
  308.    The following extended operators are preceded by a backslash `\' to
  309. distinguish them from traditional `ed' syntax.
  310.      Unconditionally matches the beginning `\`' or ending `\'' of a
  311.      line.
  312.      Optionally matches the single character regular expression or
  313.      subexpression immediately preceding it.  For example, the regular
  314.      expression `a[bd]\?c' matches the strings `abc', `adc' and `ac'.
  315.      If `\?' occurs at the beginning of a regular expressions or
  316.      subexpression, then it matches a literal `?'.
  317.      Matches the single character regular expression or subexpression
  318.      immediately preceding it one or more times.  So the regular
  319.      expression `a+' is shorthand for `aa*'.  If `\+' occurs at the
  320.      beginning of a regular expression or subexpression, then it
  321.      matches a literal `+'.
  322.      Matches the beginning or ending (null string) of a word.  Thus the
  323.      regular expression `\bhello\b' is equivalent to `\<hello\>'.
  324.      However, `\b\b' is a valid regular expression whereas `\<\>' is
  325.      not.
  326.      Matches (a null string) inside a word.
  327.      Matches any character in a word.
  328.      Matches any character not in a word.
  329. File: ed.info,  Node: Commands,  Next: Limitations,  Prev: Regular expressions,  Up: Top
  330. Commands
  331. ********
  332.    All `ed' commands are single characters, though some require
  333. additonal parameters.  If a command's parameters extend over several
  334. lines, then each line except for the last must be terminated with a
  335. backslash (`\').
  336.    In general, at most one command is allowed per line.  However, most
  337. commands accept a print suffix, which is any of `p' (print), `l'
  338. (list), or `n' (enumerate), to print the last line affected by the
  339. command.
  340.    An interrupt (typically ^C) has the effect of aborting the current
  341. command and returning the editor to command mode.
  342.    `ed' recognizes the following commands.  The commands are shown
  343. together with the default address or address range supplied if none is
  344. specified (in parenthesis).
  345. `(.)a'
  346.      Appends text to the buffer after the addressed line, which may be
  347.      the address `0' (zero).  Text is entered in input mode.  The
  348.      current address is set to last line entered.
  349. `(.,.)c'
  350.      Changes lines in the buffer.  The addressed lines are deleted from
  351.      the buffer, and text is appended in their place.  Text is entered
  352.      in input mode.  The current address is set to last line entered.
  353. `(.,.)d'
  354.      Deletes the addressed lines from the buffer.  If there is a line
  355.      after the deleted range, then the current address is set to this
  356.      line.  Otherwise the current address is set to the line before the
  357.      deleted range.
  358. `e FILE'
  359.      Edits FILE, and sets the default filename.  If FILE is not
  360.      specified, then the default filename is used.  Any lines in the
  361.      buffer are deleted before the new file is read.  The current
  362.      address is set to the last line read.
  363. `e !COMMAND'
  364.      Edits the standard output of `!COMMAND', (see the `!' command
  365.      below).  The default filename is unchanged.  Any lines in the
  366.      buffer are deleted before the output of COMMAND is read.  The
  367.      current address is set to the last line read.
  368. `E FILE'
  369.      Edits FILE unconditionally.  This is similar to the `e' command,
  370.      except that unwritten changes are discarded without warning.  The
  371.      current address is set to the last line read.
  372. `f FILE'
  373.      Sets the default filename to FILE.  If FILE is not specified, then
  374.      the default unescaped filename is printed.
  375. `(1,$)g /RE/COMMAND-LIST'
  376.      Applies COMMAND-LIST to each of the addressed lines matching a
  377.      regular expression RE.  The current address is set to the line
  378.      currently matched before COMMAND-LIST is executed.  At the end of
  379.      the `g' command, the current address is set to the last line
  380.      affected by COMMAND-LIST.
  381.      Each command in COMMAND-LIST must be on a separate line, and every
  382.      line except for the last must be terminated by a backslash (`\').
  383.      Any commands are allowed, except for `g', `G', `v', and `V'.  By
  384.      default, a newline alone in COMMAND-LIST is equivalent to a `p'
  385.      command.  If `ed' is invoked with the command-line option `-G',
  386.      then a newline in COMMAND-LIST is equivalent to a `.+1p' command.
  387. `(1,$)G /RE/'
  388.      Interactively edits the addressed lines matching a regular
  389.      expression RE.  For each matching line, the line is printed, the
  390.      current address is set, and the user is prompted to enter a
  391.      COMMAND-LIST.  At the end of the `G' command, the current address
  392.      is set to the last line affected by (the last) COMMAND-LIST.
  393.      The format of COMMAND-LIST is the same as that of the `g' command.
  394.      A newline alone acts as a null command list.  A single `&'
  395.      repeats the last non-null command list.
  396.      Toggles the printing of error explanations.  By default,
  397.      explanations are not printed.  It is recommended that ed scripts
  398.      begin with this command to aid in debugging.
  399.      Prints an explanation of the last error.
  400. `(.)i'
  401.      Inserts text in the buffer before the current line.  Text is
  402.      entered in input mode.  The current address is set to the last
  403.      line entered.
  404. `(.,.+1)j'
  405.      Joins the addressed lines.  The addressed lines are deleted from
  406.      the buffer and replaced by a single line containing their joined
  407.      text.  The current address is set to the resultant line.
  408. `(.)k LC'
  409.      Marks a line with a lower case letter LC.  The line can then be
  410.      addressed as `'LC' (i.e., a single quote followed by LC) in
  411.      subsequent commands.  The mark is not cleared until the line is
  412.      deleted or otherwise modified.
  413. `(.,.)l'
  414.      Prints the addressed lines unambiguously.  If invoked from a
  415.      terminal, `ed' pauses at the end of each page until a newline is
  416.      entered.  The current address is set to the last line printed.
  417. `(.,.)m(.)'
  418.      Moves lines in the buffer.  The addressed lines are moved to after
  419.      the right-hand destination address, which may be the address `0'
  420.      (zero).  The current address is set to the last line moved.
  421. `(.,.)n'
  422.      Prints the addressed lines along with their line numbers.  The
  423.      current address is set to the last line printed.
  424. `(.,.)p'
  425.      Prints the addressed lines.  If invoked from a terminal, `ed'
  426.      pauses at the end of each page until a newline is entered.  The
  427.      current address is set to the last line printed.
  428.      Toggles the command prompt on and off.  Unless a prompt is
  429.      specified with command-line option `-p STRING', the command prompt
  430.      is by default turned off.
  431.      Quits `ed'.
  432.      Quits `ed' unconditionally.  This is similar to the `q' command,
  433.      except that unwritten changes are discarded without warning.
  434. `($)r FILE'
  435.      Reads FILE to after the addressed line.  If FILE is not specified,
  436.      then the default filename is used.  If there is no default
  437.      filename prior to the command, then the default filename is set to
  438.      FILE.  Otherwise, the default filename is unchanged.  The current
  439.      address is set to the last line read.
  440. `($)r !COMMAND'
  441.      Reads to after the addressed line the standard output of
  442.      `!command', (see the `!' command below).  The default filename is
  443.      unchanged.  The current address is set to the last line read.
  444. `(.,.)s /RE/REPLACEMENT/'
  445. `(.,.)s /RE/REPLACEMENT/g'
  446. `(.,.)s /RE/REPLACEMENT/n'
  447.      Replaces text in the addressed lines matching a regular expression
  448.      RE with REPLACEMENT.  By default, only the first match in each
  449.      line is replaced.  If the `g' (global) suffix is given, then every
  450.      match to be replaced.  The `n' suffix, where N is a postive
  451.      number, causes only the Nth match to be replaced.  It is an error
  452.      if no substitutions are performed on any of the addressed lines.
  453.      The current address is set the last line affected.
  454.      RE and REPLACEMENT may be delimited by any character other than
  455.      space and newline (see the `s' command below).  If one or two of
  456.      the last delimiters is omitted, then the last line affected is
  457.      printed as though the print suffix `p' were specified.
  458.      An unescaped `&' in REPLACEMENT is replaced by the currently
  459.      matched text.  The character sequence `\M' where M is a number in
  460.      the range [1,9], is replaced by the Mth backreference expression
  461.      of the matched text.  If REPLACEMENT consists of a single `%',
  462.      then REPLACEMENT from the last substitution is used.  Newlines may
  463.      be embedded in REPLACEMENT if they are escaped with a backslash
  464.      (`\').
  465. `(.,.)s'
  466.      Repeats the last substitution.  This form of the `s' command
  467.      accepts a count suffix N, or any combination of the characters
  468.      `r', `g', and `p'.  If a count suffix N is given, then only the
  469.      Nth match is replaced.  The `r' suffix causes the regular
  470.      expression of the last search to be used instead of the that of
  471.      the last substitution.  The `g' suffix toggles the global suffix
  472.      of the last substitution.  The `p' suffix toggles the print suffix
  473.      of the last substitution The current address is set to the last
  474.      line affected.
  475. `(.,.)t(.)'
  476.      Copies (i.e., transfers) the addressed lines to after the
  477.      right-hand destination address, which may be the address `0'
  478.      (zero).  The current address is set to the last line copied.
  479.      Undoes the last command and restores the current address to what
  480.      it was before the command.  The global commands `g', `G', `v', and
  481.      `V' are treated as a single command by undo.  `u' is its own
  482.      inverse.
  483. `(1,$)v /RE/COMMAND-LIST'
  484.      Applies COMMAND-LIST to each of the addressed lines not matching a
  485.      regular expression RE.  This is similar to the `g' command.
  486. `(1,$)V /RE/'
  487.      Interactively edits the addressed lines not matching a regular
  488.      expression RE.  This is similar to the `G' command.
  489. `(1,$)w FILE'
  490.      Writes the addressed lines to FILE.  Any previous contents of FILE
  491.      is lost without warning.  If there is no default filename, then
  492.      the default filename is set to FILE, otherwise it is unchanged.
  493.      If no filename is specified, then the default filename is used.
  494.      The current address is unchanged.
  495. `(1,$)wq FILE'
  496.      Writes the addressed lines to FILE, and then executes a `q'
  497.      command.
  498. `(1,$)w !COMMAND'
  499.      Writes the addressed lines to the standard input of `!COMMAND',
  500.      (see the `!' command below).  The default filename and current
  501.      address are unchanged.
  502. `(1,$)W FILE'
  503.      Appends the addressed lines to the end of FILE.  This is similar
  504.      to the `w' command, expect that the previous contents of file is
  505.      not clobbered.  The current address is unchanged.
  506. `(.)x'
  507.      Copies (puts) the contents of the cut buffer to after the
  508.      addressed line.  The current address is set to the last line
  509.      copied.
  510. `(.,.)y'
  511.      Copies (yanks) the addressed lines to the cut buffer.  The cut
  512.      buffer is overwritten by subsequent `y', `s', `j', `d', or `c'
  513.      commands.  The current address is unchanged.
  514. `(.+1)z N'
  515.      Scrolls N lines at a time starting at addressed line.  If N is not
  516.      specified, then the current window size is used.  The current
  517.      address is set to the last line printed.
  518. `! COMMAND'
  519.      Executes COMMAND via `sh (1)'.  If the first character of COMMAND
  520.      is `!', then it is replaced by text of the previous `!COMMAND'.
  521.      `ed' does not process COMMAND for backslash (`\') escapes.
  522.      However, an unescaped `%' is replaced by the default filename.
  523.      When the shell returns from execution, a `!' is printed to the
  524.      standard output.  The current line is unchanged.
  525. `(.,.)#'
  526.      Begins a comment;  the rest of the line, up to a newline, is
  527.      ignored.  If a line address followed by a semicolon is given, then
  528.      the current address is set to that address.  Otherwise, the
  529.      current address is unchanged.
  530. `($)='
  531.      Prints the line number of the addressed line.
  532. `(.+1)newline'
  533.      Prints the addressed line, and sets the current address to that
  534.      line.
  535. File: ed.info,  Node: Limitations,  Next: Diagnostics,  Prev: Commands,  Up: Top
  536. Limitations
  537. ***********
  538.    The buffer files are kept in `/tmp/ed.*'.  If the terminal hangs up,
  539. `ed' attempts to write the buffer to file `ed.hup'.
  540.    `ed' processes FILE arguments for backslash escapes, i.e., in a
  541. filename, any characters preceded by a backslash (`\') are interpreted
  542. literally.
  543.    If a text (non-binary) file is not terminated by a newline character,
  544. then `ed' appends one on reading/writing it.  In the case of a binary
  545. file, `ed' does not append a newline on reading/writing.
  546.    Per line overhead: 4 `int's.
  547. File: ed.info,  Node: Diagnostics,  Prev: Limitations,  Up: Top
  548. Diagnostics
  549. ***********
  550.    When an error occurs, if `ed''s input is from a regular file or here
  551. document, then it exits, otherwise it prints a `?' and returns to
  552. command mode.  An explanation of the last error can be printed with the
  553. `h' (help) command.
  554. If the `u' (undo) command occurs in a global command list, then the
  555. command list is executed only once.
  556.    Attempting to quit `ed' or edit another file before writing a
  557. modified buffer results in an error.  If the command is entered a
  558. second time, it succeeds, but any changes to the buffer are lost.
  559.    `ed' exits with 0 if no errors occurred; otherwise >0.
  560. Tag Table:
  561. Node: Top
  562. Node: Intro
  563. Node: Invoking ed
  564. Node: Line addressing
  565. Node: Regular expressions
  566. 11591
  567. Node: Commands
  568. 16977
  569. Node: Limitations
  570. 27863
  571. Node: Diagnostics
  572. 28481
  573. End Tag Table
  574.