Annotation of 43BSDReno/foreign/man/ed.0, revision 1.1.1.1

1.1       root        1: ED(1)                      UNIX Reference Manual                        ED(1)
                      2: 
                      3: NNAAMMEE
                      4:      eedd - text editor
                      5: 
                      6: SSYYNNOOPPSSIISS
                      7:      eedd [--] [_f_i_l_e]
                      8: 
                      9: DDEESSCCRRIIPPTTIIOONN
                     10:      EEdd is the standard text editor.
                     11: 
                     12:      If a _f_i_l_e argument is given, eedd simulates an ee command (see below) on the
                     13:      named file; that is to say, the file is read into eedd ''ss buffer so that it
                     14:      can be edited.
                     15: 
                     16:      --          Suppresses the printing of explanatory output and should be used
                     17:           when the standard input is an editor script.
                     18: 
                     19:      EEdd operates on a copy of any file it is editing; changes made in the copy
                     20:      have no effect on the file until a ww (write) command is given.  The copy
                     21:      of the text being edited resides in a temporary file called the _b_u_f_f_e_r.
                     22: 
                     23:      Commands to eedd have a simple and regular structure: zero or more
                     24:      _a_d_d_r_e_s_s_e_s followed by a single character _c_o_m_m_a_n_d, possibly followed by
                     25:      parameters to the command.  These addresses specify one or more lines in
                     26:      the buffer.  Missing addresses are supplied by default.
                     27: 
                     28:      In general, only one command may appear on a line.  Certain commands al-
                     29:      low the addition of text to the buffer.  While eedd is accepting text, it
                     30:      is said to be in _i_n_p_u_t _m_o_d_e.  In this mode, no commands are recognized;
                     31:      all input is merely collected.  Input mode is left by typing a period `..'
                     32:      alone at the beginning of a line.
                     33: 
                     34:      EEdd supports a limited form of _r_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n notation.  A regular ex-
                     35:      pression specifies a set of strings of characters.  A member of this set
                     36:      of strings is said to be _m_a_t_c_h_e_d by the regular expression.  In the fol-
                     37:      lowing specification for regular expressions the word `character' means
                     38:      any character but newline.
                     39: 
                     40:      1.    Any character except a special character matches itself.  Special
                     41:           characters are the regular expression delimiter plus `\\[[..' and
                     42:           sometimes `^^**$$'.
                     43: 
                     44:      2.    A `..' matches any character.
                     45: 
                     46:      3.    A `\' followed by any character except a digit or () matches that
                     47:           character.
                     48: 
                     49:      4.    A nonempty string [_s] or ([^^_s]) matches any character in (or not
                     50:           in) _s.  In _s, `\' has no special meaning, and may only appear as
                     51:           the first letter.  A substring _a-_b, with _a and _b in ascending ASCII
                     52:           order, stands for the inclusive range of ASCII characters.
                     53: 
                     54:      5.    A regular expression of form 1-4 followed by * matches a sequence
                     55:           of 0 or more matches of the regular expression.
                     56: 
                     57:      6.    A regular expression, _x, of form 1-8, bracketed \(_x\) matches what
                     58:           _x matches.
                     59: 
                     60:      7.    A \ followed by a digit _n matches a copy of the string that the
                     61:           bracketed regular expression beginning with the _n'th \( matched.
                     62: 
                     63:      8.    A regular expression of form 1-8, _x, followed by a regular expres-
                     64:           sion of form 1-7, _y matches a match for _x followed by a match for
                     65:           _y, with the _x match being as long as possible while still permit-
                     66:           ting a _y match.
                     67:      9.    A regular expression of form 1-8 preceded by `^' (or followed by
                     68:           `$'), is constrained to matches that begin at the left (or end at
                     69:           the right) end of a line.
                     70: 
                     71:      10.   A regular expression of form 1-9 picks out the longest among the
                     72:           leftmost matches in a line.
                     73: 
                     74:      11.   An empty regular expression stands for a copy of the last regular
                     75:           expression encountered.
                     76: 
                     77:      Regular expressions are used in addresses to specify lines and in one
                     78:      command (see _s below) to specify a portion of a line which is to be re-
                     79:      placed.  If it is desired to use one of the regular expression metachar-
                     80:      acters as an ordinary character, that character may be preceded by `\'.
                     81:      This also applies to the character bounding the regular expression (often
                     82:      `/') and to `\' itself.
                     83: 
                     84:      To understand addressing in eedd it is necessary to know that at any time
                     85:      there is a _c_u_r_r_e_n_t _l_i_n_e.  Generally speaking, the current line is the
                     86:      last line affected by a command; however, the exact effect on the current
                     87:      line is discussed under the description of the command.  Addresses are
                     88:      constructed as follows.
                     89: 
                     90:      1.    The character `..' addresses the current line.
                     91: 
                     92:      2.    The character `$$' addresses the last line of the buffer.
                     93: 
                     94:      3.    A decimal number _n addresses the _n'th line of the buffer.
                     95: 
                     96:      4.    `'_x' addresses the line marked with the name _x, which must be a
                     97:           lower-case letter.  Lines are marked with the _k command described
                     98:           below.
                     99: 
                    100:      5.    A regular expression enclosed in slashes `/' addresses the line
                    101:           found by searching forward from the current line and stopping at
                    102:           the first line containing a string that matches the regular
                    103:           expression.  If necessary the search wraps around to the beginning
                    104:           of the buffer.
                    105: 
                    106:      6.    A regular expression enclosed in queries `?' addresses the line
                    107:           found by searching backward from the current line and stopping at
                    108:           the first line containing a string that matches the regular
                    109:           expression.  If necessary the search wraps around to the end of the
                    110:           buffer.
                    111: 
                    112:      7.    An address followed by a plus sign `+' or a minus sign `-' followed
                    113:           by a decimal number specifies that address plus (resp. minus) the
                    114:           indicated number of lines.  The plus sign may be omitted.
                    115: 
                    116:      8.    If an address begins with `+' or `-' the addition or subtraction is
                    117:           taken with respect to the current line; e.g.  `-5' is understood to
                    118:           mean `.-5' .
                    119: 
                    120:      9.    If an address ends with `+' `-', then 1 is added (resp.
                    121:           subtracted).  As a consequence of this rule and rule 8, the address
                    122:           `-' refers to the line before the current line.  Moreover, trailing
                    123:           `+' and `-' characters have cumulative effect, so `--' refers to
                    124:           the current line less 2.
                    125: 
                    126:      10.   To maintain compatibility with earlier versions of the editor, the
                    127:           character `^' in addresses is equivalent to `-'.
                    128: 
                    129:      Commands may require zero, one, or two addresses. Commands which require
                    130:      no addresses regard the presence of an address as an error.  Commands
                    131:      which accept one or two addresses assume default addresses when
                    132:      insufficient are given.  If more addresses are given than such a command
                    133:      requires, the last one or two (depending on what is accepted) are used.
                    134: 
                    135:      Addresses are separated from each other typically by a comma `,' They may
                    136:      also be separated by a semicolon `;' In this case the current line `.' .
                    137:      is set to the previous address before the next address is interpreted.
                    138:      This feature can be used to determine the starting line for forward and
                    139:      backward searches (`/' `?').  The second address of any two-address
                    140:      sequence must correspond to a line following the line corresponding to
                    141:      the first address.  The special form `%' is an abbreviation for the
                    142:      address pair `1,$'.
                    143: 
                    144:      In the following list of eedd commands, the default addresses are shown in
                    145:      parentheses.  The parentheses are not part of the address, but are used
                    146:      to show that the given addresses are the default.
                    147: 
                    148:      As mentioned, it is generally illegal for more than one command to appear
                    149:      on a line.  However, most commands may be suffixed by `p' or by `l', in
                    150:      which case the current line is either printed or listed respectively in
                    151:      the way discussed below.  Commands may also be suffixed by `n', meaning
                    152:      the output of the command is to be line numbered. These suffixes may be
                    153:      combined in any order.
                    154: 
                    155:      (.)aa
                    156: 
                    157:      <text>
                    158: 
                    159:      ..          The append command reads the given text and appends it after the
                    160:           addressed line.  `..' is left on the last line input, if there were
                    161:           any, otherwise at the addressed line.  Address `0' is legal for
                    162:           this command; text is placed at the beginning of the buffer.
                    163: 
                    164:      (..,..)cc
                    165: 
                    166:      <text>
                    167: 
                    168:      ..          The change command deletes the addressed lines, then accepts input
                    169:           text which replaces these lines.  `..' is left at the last line in-
                    170:           put; if there were none, it is left at the line preceding the
                    171:           deleted lines.
                    172: 
                    173:      (..,..)dd
                    174:           The delete command deletes the addressed lines from the buffer.
                    175:           The line originally after the last line deleted becomes the current
                    176:           line; if the lines deleted were originally at the end, the new last
                    177:           line becomes the current line.
                    178: 
                    179:      ee _f_i_l_e_n_a_m_e
                    180:           The edit command causes the entire contents of the buffer to be
                    181:           deleted, and then the named file to be read in.  `..' is set to the
                    182:           last line of the buffer.  The number of characters read is typed.
                    183:           _f_i_l_e_n_a_m_e is remembered for possible use as a default file name in a
                    184:           subsequent rr or ww command.  If _f_i_l_e_n_a_m_e is missing, the remembered
                    185:           name is used.
                    186: 
                    187:      EE _f_i_l_e_n_a_m_e
                    188:           This command is the same as ee, except that no diagnostic results
                    189:           when no ww has been given since the last buffer alteration.
                    190: 
                    191:      ff _f_i_l_e_n_a_m_e
                    192:           The filename command prints the currently remembered file name.  If
                    193:           _f_i_l_e_n_a_m_e is given, the currently remembered file name is changed to
                    194:           _f_i_l_e_n_a_m_e.
                    195: 
                    196:      (1,$$)gg/_r_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n/_c_o_m_m_a_n_d _l_i_s_t
                    197:           In the global command, the first step is to mark every line which
                    198:           matches the given regular expression.  Then for every such line,
                    199:           the given command list is executed with `..' initially set to that
                    200:           line.  A single command or the first of multiple commands appears
                    201:           on the same line with the global command.  All lines of a multi-
                    202:           line list except the last line must be ended with `\\'.  AA, ii,, and cc
                    203:           commands and associated input are permitted; the `..' terminating
                    204:           input mode may be omitted if it would be on the last line of the
                    205:           command list.  The commands gg and vv are not permitted in the com-
                    206:           mand list.
                    207: 
                    208:      (.)ii
                    209: 
                    210:      <text>
                    211: 
                    212:      ..          This command inserts the given text before the addressed line.  `..'
                    213:           is left at the last line input, or, if there were none, at the line
                    214:           before the addressed line.  This command differs from the aa command
                    215:           only in the placement of the text.
                    216: 
                    217:      (..,..++11)jj
                    218:           This command joins the addressed lines into a single line;
                    219:           intermediate newlines simply disappear.  `..' is left at the
                    220:           resulting line.
                    221: 
                    222:      (.)kk_x
                    223:           The mark command marks the addressed line with name _x, which must
                    224:           be a lower-case letter.  The address form `'_x' then addresses this
                    225:           line.
                    226: 
                    227:      (..,..)ll
                    228:           The list command prints the addressed lines in an unambiguous way:
                    229:           non-graphic characters are printed in two-digit octal, and long
                    230:           lines are folded.  The _l command may be placed on the same line
                    231:           after any non-i/o command.
                    232: 
                    233:      (..,..)mm_a
                    234:           The move command repositions the addressed lines after the line
                    235:           addressed by _a.  The last of the moved lines becomes the current
                    236:           line.
                    237: 
                    238:      (..,..)pp
                    239:           The print command prints the addressed lines.  `..' is left at the
                    240:           last line printed.  The pp command may be placed on the same line
                    241:           after any non-i/o command.
                    242: 
                    243:      (..,..)PP
                    244:           This command is a synonym for pp.
                    245: 
                    246:      qq          The quit command causes eedd to exit.      No automatic write of a file
                    247:           is done.
                    248: 
                    249:      QQ          This command is the same as qq, except that no diagnostic results
                    250:           when no ww has been given since the last buffer alteration.
                    251: 
                    252:      ($$)rr _f_i_l_e_n_a_m_e
                    253:           The read command reads in the given file after the addressed line.
                    254:           If no file name is given, the remembered file name, if any, is used
                    255:           (see ee and ff commands).  The file name is remembered if there was
                    256:           no remembered file name already.  Address `0' is legal for rr and
                    257:           causes the file to be read at the beginning of the buffer.  If the
                    258:           read is successful, the number of characters read is typed.  `..' is
                    259:           left at the last line read in from the file.
                    260: 
                    261:      (..,..)ss/_r_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n/_r_e_p_l_a_c_e_m_e_n_t/  or
                    262: 
                    263:      (..,..)ss/_r_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n/_r_e_p_l_a_c_e_m_e_n_t/gg
                    264:           The substitute command searches each addressed line for an
                    265:           occurrence of the specified regular expression.  On each line in
                    266:           which a match is found, all matched strings are replaced by the
                    267:           replacement specified, if the global replacement indicator gg ap-
                    268:           pears after the command.  If the global indicator does not appear,
                    269:           only the first occurrence of the matched string is replaced.  It is
                    270:           an error for the substitution to fail on all addressed lines.  Any
                    271:           punctuation character may be used instead of `//' to delimit the
                    272:           regular expression and the replacement.  `..' is left at the last
                    273:           line substituted.  An ampersand `&&' appearing in the replacement is
                    274:           replaced by the string matching the regular expression.  The
                    275:           special meaning of `&&' in this context may be suppressed by
                    276:           preceding it by `\\'.  The characters `\\_n' where _n is a digit, are
                    277:           replaced by the text matched by the _n'th regular subexpression
                    278:           enclosed between `\\(('.  and `\\))'.  When nested, parenthesized
                    279:           subexpressions are present, _n is determined by counting occurrences
                    280:           of `\\(('.  starting from the left.  Lines may be split by
                    281:           substituting new-line characters into them.  The new-line in the
                    282:           replacement string must be escaped by preceding it by `\\'.  One or
                    283:           two trailing delimiters may be omitted, implying the pp suffix.  The
                    284:           special form ss followed by _n_o delimiters repeats the most recent
                    285:           substitute command on the addressed lines.  The ss may be followed
                    286:           by the letters rr (use the most recent regular expression for the
                    287:           left hand side, instead of the most recent left hand side of a sub-
                    288:           stitute command), pp (complement the setting of the pp suffix from
                    289:           the previous substitution), or gg (complement the setting of the gg
                    290:           suffix).  These letters may be combined in any order.
                    291: 
                    292:      (..,..)tt_a
                    293:           This command acts just like the mm command, except that a copy of
                    294:           the addressed lines is placed after address _a (which may be 0).
                    295:           `..' is left on the last line of the copy.
                    296: 
                    297:      (..,..)uu
                    298:           The undo command restores the buffer to it's state before the most
                    299:           recent buffer modifying command.  The current line is also
                    300:           restored.  Buffer modifying commands are aa, cc, dd, gg, ii and vv.  For
                    301:           purposes of undo, gg and vv are considered to be a single buffer
                    302:           modifying command.  Undo is its own inverse.  When eedd runs out of
                    303:           memory (at about 8000 lines on any 16 bit mini-computer such as the
                    304:           PDP-11) This full undo is not possible, and uu can only undo the ef-
                    305:           fect of the most recent substitute on the current line.  This res-
                    306:           tricted undo also applies to editor scripts when eedd is invoked with
                    307:           the -- option.
                    308: 
                    309:      (1,$$)vv/_r_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n/_c_o_m_m_a_n_d _l_i_s_t
                    310:           This command is the same as the global command gg except that the
                    311:           command list is executed gg with `..' initially set to every line
                    312:           _e_x_c_e_p_t those matching the regular expression.  (1, $) 192.Tp Cx ( 1
                    313:           ,$$)ww _f_i_l_e_n_a_m_e The write command writes the addressed lines onto the
                    314:           given file.  If the file does not exist, it is created.  The file
                    315:           name is remembered if there was no remembered file name already.
                    316:           If no file name is given, the remembered file name, if any, is used
                    317:           (see ee and ff commands).  `..' is unchanged.  If the command is
                    318:           successful, the number of characters written is printed.
                    319: 
                    320:      (1,$$)WW _f_i_l_e_n_a_m_e
                    321:           This command is the same as ww, except that the addressed lines are
                    322:           appended to the file.
                    323: 
                    324:      (1,$$)wwqq _f_i_l_e_n_a_m_e
                    325:           This command is the same as ww except that afterwards a qq command is
                    326:           done, exiting the editor after the file is written.  1 ++11 )zz  or,
                    327: 
                    328:      (1++11)zz_n
                    329:           This command scrolls through the buffer starting at the addressed
                    330:           line.  22 (or _n, if given) lines are printed.  The last line print-
                    331:           ed becomes the current line.  The value _n is sticky, in that it be-
                    332:           comes the default for future zz commands.
                    333: 
                    334:      ($$)==
                    335:           The line number of the addressed line is typed.  `..' is unchanged
                    336:           by this command.
                    337: 
                    338:      !!<shell command>
                    339:           The remainder of the line after the `!' is sent to sh(1) to be
                    340:           interpreted as a command.  `..' is unchanged.
                    341: 
                    342:      (..++11,..++11)<newline>
                    343:           An address alone on a line causes the addressed line to be printed.
                    344:           A blank line alone is equivalent to ..++11 it is useful for stepping
                    345:           through text.  If two addresses are present with no intervening
                    346:           semicolon, eedd prints the range of lines.  If they are separated by
                    347:           a semicolon, the second line is printed.
                    348: 
                    349:      If an interrupt signal (ASCII DEL) is sent, eedd prints `?interrupted' and
                    350:      returns to its command level.
                    351: 
                    352:      Some size limitations: 512 characters per line, 256 characters per global
                    353:      command list, 64 characters per file name, and, on mini computers, 128K
                    354:      characters in the temporary file. The limit on the number of lines
                    355:      depends on the amount of core: each line takes 2 words.
                    356: 
                    357:      When reading a file, eedd discards ASCII NUL characters and all characters
                    358:      after the last newline.  It refuses to read files containing non-ASCII
                    359:      characters.
                    360: 
                    361: FFIILLEESS
                    362:      /_t_m_p/_e*
                    363:      _e_d_h_u_p   work is saved here if terminal hangs up
                    364: 
                    365: 
                    366: SSEEEE AALLSSOO
                    367:      ex(1), sed(1), crypt(1)
                    368:      B. W. Kernighan, _A _T_u_t_o_r_i_a_l _I_n_t_r_o_d_u_c_t_i_o_n _t_o _t_h_e _E_D _T_e_x_t _E_d_i_t_o_r
                    369:      B. W. Kernighan, _A_r _A_d_v_a_n_c_e_d _e_d_i_t_i_n_g _o_n _U_N_I_X
                    370: 
                    371: HHIISSTTOORRYY
                    372:      The eedd command appeared in Version 6 AT&T UNIX.
                    373: 
                    374: DDIIAAGGNNOOSSTTIICCSS
                    375:      `name' for inaccessible file; `?self-explanatory message' for other er-
                    376:      rors.
                    377: 
                    378:      To protect against throwing away valuable work, a qq or ee command is con-
                    379:      sidered to be in error, unless a ww has occurred since the last buffer
                    380:      change.  A second qq or ee will be obeyed regardless.
                    381: 
                    382: BBUUGGSS
                    383:      The ll command mishandles DEL.
                    384:      The uunnddoo command causes marks to be lost on affected lines.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.