home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / ed.info (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  24KB  |  458 lines

  1. This is Info file ed.info, produced by Makeinfo-1.55 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: Description,  Prev: (dir),  Up: (dir)
  18.    This file documents the `ed' command, as of release 0.1.  You may
  19. find in this document:
  20. * Menu:
  21. * Description::                 Description
  22. * Invoking::                    Invoking GNU `ed'
  23. * Line addressing::             Line addressing
  24. * Regular expressions::         Regular expressions
  25. * Commands::                    Commands
  26. * Limitations::                 Limitations
  27. * Diagnostics::                 Diagnostics
  28. File: ed.info,  Node: Description,  Next: Invoking,  Prev: Top,  Up: Top
  29. Description
  30. ***********
  31.    `ed' is a line-oriented text editor.  It is used to create, display,
  32. modify and otherwise manipulate text files.  `red' is a restricted
  33. `ed': it can only edit files in the current directory and cannot
  34. execute shell commands.
  35.    Related programs or routines are `vi (1)', `sed (1)', `regex (3)',
  36. `bdes (1)' and `sh (1)'.  Related documents are `USD:12-13' and:
  37.      B. W. Kernighan and P. J. Plauger: "Software Tools in Pascal",
  38.      Addison-Wesley, 1981.
  39.    If invoked with a FILE argument, then a copy of FILE is read into
  40. the editor's buffer.  Changes are made to this copy and not directly to
  41. FILE itself.  Upon quitting `ed', any changes not explicitly saved with
  42. a `w' command are lost.
  43.    Editing is done in two distinct modes: "command" and "input".  When
  44. first invoked, `ed' is in command mode.  In this mode commands are read
  45. from the standard input and executed to manipulate the contents of the
  46. editor buffer.  A typical command might look like:
  47.      ,s/OLD/NEW/g
  48. which replaces all occurences of the string OLD with NEW.
  49.    When an input command, such as `a' (append), `i' (insert) or `c'
  50. (change), is given, `ed' enters input mode.  This is the primary means
  51. of adding text to a file.  In this mode, no commands are available;
  52. instead, the standard input is written directly to the editor buffer.
  53. The text up to and including a newline character defines a single line.
  54. Input mode is terminated by entering a single period (`.') on a line.
  55.    All `ed' commands operate on whole lines or ranges of lines; e.g.,
  56. the `d' command deletes lines; the `m' command moves lines, and so on.
  57. It is possible to modify only a portion of a line by means of
  58. replacement, as in the example above.  However even here, the `s'
  59. command is applied to whole lines at a time.
  60.    In general, `ed' commands consist of zero or more line addresses,
  61. followed by a single character command and possibly additional
  62. parameters; i.e., commands have the structure:
  63.      [ADDRESS [,ADDRESS]]COMMAND[PARAMETERS]
  64.    The ADDRESS(es) indicate the line or range of lines to be affected
  65. by the command.  If fewer addresses are given than the command accepts,
  66. then default addresses are supplied.
  67. File: ed.info,  Node: Invoking,  Next: Line addressing,  Prev: Description,  Up: Top
  68. Invoking GNU `ed'
  69. *****************
  70.      ed [-] [-Gs] [-p STRING] [FILE]
  71.      red [-] [-Gs] [-p STRING] [FILE]
  72.      Forces backwards compatibility.  This affects the behavior of the
  73.      `ed' commands `G', `f', `l', `m', `t' and `!!'.  If the default
  74.      behavior of these commands does not seem familiar, then try
  75.      invoking `ed' with this switch.
  76.      Suppresses diagnostics. This should be used if `ed''s standard
  77.      input is from a script.
  78. `-p STRING'
  79.      Specifies a command prompt.  This may be toggled on and off with
  80.      the `P' command.
  81.    FILE specifies the name of a file to read.  If FILE is prefixed with
  82. a bang (!), then it is interpreted as a shell command.  In this case,
  83. what is read is the standard output of FILE executed via `sh (1)'.  To
  84. read a file whose name begins with a bang, prefix the name with a
  85. backslash (`\').  The default filename is set to FILE only if it is not
  86. prefixed with a bang.
  87. File: ed.info,  Node: Line addressing,  Next: Regular expressions,  Prev: Invoking,  Up: Top
  88. Line addressing
  89. ***************
  90.    An address represents the number of a line in the buffer.  `ed'
  91. maintains a "current address" which is typically supplied to commands
  92. as the default address when none is specified.  When a file is first
  93. read, the current address is set to the last line of the file.  In
  94. general, the current address is set to the last line affected by a
  95. command.
  96.    A line address is constructed from one of the bases in the list
  97. below, optionally followed by a numeric offset.  The offset may include
  98. any combination of digits, operators (i.e., `+', `-' and `^') and
  99. whitespace.  Addresses are read from left to right, and their values
  100. are computed relative to the current address.
  101.    One exception to the rule that addresses represent line numbers is
  102. the address `0' (zero).  This means "before the first line," and is
  103. legal wherever it makes sense.
  104.    An address range is two addresses separated either by a comma or
  105. semi-colon. The value of the first address in a range cannot exceed the
  106. value of the the second.  If only one address is given in a range, then
  107. the second address is set to the given address.  If an N-tuple of
  108. addresses is given where N > 2, then the corresponding range is
  109. determined by the last two addresses in the N-tuple.  If only one
  110. address is expected, then the last address is used.
  111.    Each address in a comma-delimited range is interpreted relative to
  112. the current address.  In a semi-colon-delimited range, the first
  113. address is used to set the current address, and the second address is
  114. interpreted relative to the first.
  115.    The following address symbols are recognized.
  116.      The current line (address) in the buffer.
  117.      The last line in the buffer.
  118.      The Nth, line in the buffer where N is a number in the range `0,$'.
  119.      The previous line.  This is equivalent to `-1' and may be repeated
  120.      with cumulative effect.
  121.      The Nth previous line, where N is a non-negative number.
  122.      The next line.  This is equivalent to `+1' and may be repeated with
  123.      cumulative effect.
  124. `WHITESPACE N'
  125.      The Nth next line, where N is a non-negative number.  Whitespace
  126.      followed by a number N is interpreted as `+N'.
  127.      The first through last lines in the buffer.  This is equivalent to
  128.      the address range `1,$'.
  129.      The current through last lines in the buffer.  This is equivalent
  130.      to the address range `.,$'.
  131. `/RE/'
  132.      The next line containing the regular expression RE.  The search
  133.      wraps to the beginning of the buffer and continues down to the
  134.      current line, if necessary.  `//' repeats the last search.
  135. `?RE?'
  136.      The previous line containing the regular expression RE.  The
  137.      search wraps to the end of the buffer and continues up to the
  138.      current line, if necessary.  `??' repeats the last search.
  139. `'LC'
  140.      The line previously marked by a `k' (mark) command, where LC is a
  141.      lower case letter.
  142. File: ed.info,  Node: Regular expressions,  Next: Commands,  Prev: Line addressing,  Up: Top
  143. Regular expressions
  144. *******************
  145.    Regular expressions are patterns used in selecting text.  For
  146. example, the `ed' command
  147.      g/STRING/
  148. prints all lines containing STRING.  Regular expressions are also used
  149. by the `s' command for selecting old text to be replaced with new.
  150.    In addition to a specifying string literals, regular expressions can
  151. represent classes of strings.  Strings thus represented are said to be
  152. matched by the correspondi