home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ed.zip / ed.man < prev    next >
Text File  |  1989-12-05  |  7KB  |  139 lines

  1. ed - line-oriented text editor, similar to UN*X V7 ed
  2.  
  3. syntax:
  4.     ed [existing-file]
  5.  
  6.     existing-file  Only an existing file can be opened.  Otherwise
  7.         a nameless edit buffer is opened; a name can be used with
  8.         the `f' or `w' commands.
  9.  
  10. As a line editor, ed operates in one of two modes: COMMAND mode, in which
  11. a colon is displayed at the screen's bottom to prompt for a command; and
  12. INPUT mode, in which all keyboard input is added to the file (edit buffer).
  13. From COMMAND mode, INPUT mode is entered by either the `i' or `a' commands.
  14. From INPUT mode, the COMMAND mode is restored by entering a line consisting
  15. of a single period by itself.  If such a line is desired in the file, it
  16. can be created by entering (for instance) two periods, then using the `s'
  17. command to change these to only one period.
  18.  
  19. A command consists of an optional line-range specification, a single char-
  20. acter indicating the command, and for some commands an optional third
  21. argument.  The line-range specification is either a single line number or
  22. a first-line number and a last-line number separated by a comma.  The
  23. character `^' means the first line of the file; `$' means the last line
  24. of the file.
  25.  
  26. Commands:
  27.     <newline>
  28.     If a line is specified, make that the new current line.
  29.     Otherwise advance the current-line-pointer by one line.
  30.     =    Print the line number of the current line.
  31.     .    (by itself)  Print the current line.
  32.     -    (by itself)  Move the current-line-pointer back one, and print
  33.     the new current line.
  34.     +    (by itself)  Move the current-line-pointer forward one, and
  35.     print the new current line.
  36.     !    Execute a shell command and return.
  37.     a    Go into INPUT mode with a new line following the current line.
  38.     (INPUT mode is terminated by an input line containing only a
  39.     period in the first column.)
  40.     i    Go into INPUT mode with a new line preceding the current line.
  41.     (INPUT mode is terminated by an input line containing only a
  42.     period in the first column.)
  43.     c    Delete the specified lines (or the current line) and then
  44.     add new lines in their place.  This is equivalent to a `d'
  45.     command followed by an `i' command.
  46.     d    Delete the specified range of lines (or the current line).
  47.     Leave the current-line-pointer at the following line.
  48.     e    Clear the edit buffer and begin editing a new file.  This
  49.     command fails if the buffer contains changes (or new lines)
  50.     which have not been written out.  To discard these changes
  51.     and edit a new file, use `E' instead of `e'.
  52.     E    Clear the edit buffer and begin editing a new file, regardless
  53.     of any changes to the current edit buffer.
  54.     f    Print the filename, or set it to a new name if specified.
  55.     g    Perform the following command on all matching lines in range
  56.     j    Join the addressed lines together (or the current line to the
  57.     previous line).
  58.     k    Mark the addressed line with the specified letter.  Example:
  59.     `17ka' puts mark "a" on line 17.
  60.     l    List the addressed lines, showing all non-printing characters
  61.     and indicating the end-of-line.
  62.     m    Move the specified range of lines to follow the line number
  63.     given.  Example:  `5,7m3' moves lines 5 through 7 "up", to
  64.     follow line 3.
  65.   p,P    Print the specified lines.
  66.     q    Quit the editor.  This fails if the edit buffer contains any
  67.     changes.  If so, use `Q' instead.
  68.     Q    Quit the editor absolutely.  Any changes are discarded.
  69.     r    Read in a file, adding it after the current line.
  70.     s    Substitute text on the current line.  Example:  `s/alpha/beta/'
  71.     finds the string "alpha" and replaces it with "beta".
  72.     t    Transfer (copy) the specified range of lines to follow the line
  73.     number given.  Example:  `5,7t7' puts a copy of lines 5 through
  74.     7 after line 7.
  75.     v    Perform the following command on all non-matching lines in range
  76.   w,W    Write the edit buffer out.  If a filename is given, it is used
  77.     and becomes the current filename.  If a range of lines is
  78.     specified, only those lines are written.
  79.     x    Write the entire buffer out to its file, and terminate.
  80.     z    Print 21 lines.  `-', `.', or `+' may be given, and mean
  81.     "start 21 lines previous, end at current line",
  82.     "start 11 lines previous, end 10 lines hence", or
  83.     "start at current line, end 21 lines from here", respectively.
  84.  
  85. The syntax of g and v is  <addrs> g /re/ <command>
  86.  
  87. BUGS and COMMENTS
  88.  
  89. There's no "u" command. Reading files is still pretty slow. IGP.
  90.  
  91. [Here's an example of how to split a line:  .s/BUGS/BU\nGS/
  92. The backslash n (\n) ends the current line after the U and starts another
  93. line beginning with G.  -Ed L]
  94.  
  95. The code started out as many small files.  It is now one file, but the
  96. result isn't as clean as it could be.  I've cleaned it up some, but in
  97. converting it to TurboC compliancy I've probably lost generic C compliancy.
  98. Headers describing its distribution history are appended to the code.
  99.  
  100. [The i variable in function doprnt() has been eliminated and replaced by
  101. the global variable CurLn.  MSDOS signal code has been added to intercept
  102. CTRL C and CTRL [BREAK] so that the program does not abort your work when
  103. you press either of these key sequences.  -Ed L]
  104.  
  105. AUTHORS
  106.  
  107. Brian Beattie seems to be the original author.  Kees Bot is associated
  108. with it.  Andy Tanenbaum ported it to MINIX, and posted it to Usenet.
  109. Bob Montante ported it to MSDOS and did some minor dressing-up.
  110. Somebody called Ed L added some comments above.
  111.  
  112. This version is derived from the one posted in comp.binaries.ibm.pc in ?early
  113. 1988.
  114. Ian Phillipps replaced the regexp stuff with Henry Spencer's version, and
  115. did some other speed-ups and tinkerings. See below.
  116. Lewis Carroll wrote Alice's Adventures in Wonderland;
  117. James Joyce wrote Finnegans Wake; they are clearly the spiritual wellsprings.
  118. [I think Dennis Ritchie deserves a mention here, too. IGP]
  119.  
  120. [The ed.c source contains an untoggled switch for displaying line
  121. numbers and another for stripping high bits off characters.  If you
  122. type "se" at the ":" prompt, you will get a decimal version number.
  123. -Ed L]
  124.  
  125. Changes by IGP since the last comp.binaries.ibm.pc posting:
  126.  
  127. Regular expression code replaced with Henry Spencer's (lightly hacked).
  128. Unneccessary text copying eliminated, and the remaining quadratic-time
  129. algorithms to track line numbers removed. The program now remembers a pointer
  130. to the current line.
  131. All this has speeded up "g" by a factor of 20-50, so now I've documented it :-).
  132. Logic fixed in egets to eliminate redundant tests.
  133. A bug in <multiline> s/.../\n/ has been fixed.
  134. All out-of-memory errors should now be reported (many were ignored before).
  135. A Turbo-C dependency ("cdecl") has been #ifdefed.
  136. All routines now have prototypes.
  137. Ian Phillipps (probably contactable via ex-igp@camcon.co.uk,
  138. but don't bank on it)
  139.