a file is first read, the current address is set to the last line of the file. In general, the current address is set to the last line affected by a command. A line address is constructed from one of the bases in the list below, optionally followed by a numeric offset. The offset may include any combination of digits, operators (e.g., ‘
-’, and ‘
^’), and whitespace. Addresses are read from left to right, and their values are computed relative to the current address. One exception to the rule that addresses represent line numbers is the address 0 (zero). This means “before the first line”, and is legal wherever it makes sense. An address range is two addresses separated either by a comma or semi-colon. The value of the first address in a range cannot exceed the value of the second. If only one address is given in a range, then the second address is set to the given address. If an n-tuple of addresses is given where n > 2, then the corresponding range is determined by the last two addresses in the n-tuple. If only one address is expected, then the last address is used. Each address in a comma-delimited range is interpreted relative to the current address. In a semi-colon-delimited range, the first address is used to set the current address, and the second address is interpreted relative to the first. The following address symbols are recognized:
k(mark) command, where lc is a lower case letter.
edcommands are single characters, though some require additional parameters. If a command's parameters extend over several lines, then each line except for the last must be terminated with a backslash (‘
\’). In general, at most one command is allowed per line. However, most commands accept a print suffix, which is any of
n(enumerate), to print the last line affected by the command.
edrecognizes the following commands. The commands are shown together with the default address or address range supplied if none is specified (in parentheses), and other possible arguments on the right.
!command below). The default filename is unchanged. Any lines in the buffer are deleted before the output of command is read. The current address is set to the last line read.
ecommand, except that unwritten changes are discarded without warning. The current address is set to the last line read.
gcommand, the current address is set to the last line affected by command-list. If no lines were matched, the current line number remains unchanged. Each command in command-list must be on a separate line, and every line except for the last must be terminated by a backslash (‘\’). Any commands are allowed, except for
V. A newline alone in command-list is equivalent to a
Gcommand, the current address is set to the last line affected by (the last) command-list. If no lines were matched, the current line number remains unchanged. The format of command-list is the same as that of the
gcommand. A newline alone acts as a null command list. A single ‘&’ repeats the last non-null command list.
edscripts begin with this command to aid in debugging.
'lc (i.e., a single quote followed by lc) in subsequent commands. The mark is not cleared until the line is deleted or otherwise modified.
-pstring, the command prompt is by default turned off.
edunconditionally. This is similar to the
qcommand, except that unwritten changes are discarded without warning.
!command below). The default filename is unchanged. The current address is set to the last line read.
g(global) suffix is given, then every match is replaced. The n suffix, where n is a positive number, causes only the nth match to be replaced. It is an error if no substitutions are performed on any of the addressed lines. The current address is set the last line affected. re and replacement may be delimited by any character other than space and newline (see the
scommand below). If one or two of the last delimiters is omitted, then the last line affected is printed as though the print suffix
pwere specified. An unescaped ‘
&’ in replacement is replaced by the currently matched text. The character sequence \m, where m is a numbe