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

unix.superglobalmegacorp.com

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