(ed.info.gz) Line Addressing
Info Catalog
(ed.info.gz) Invoking Ed
(ed.info.gz) Top
(ed.info.gz) Regular Expressions
4 Line Addressing
*****************
An address represents the number of a line in the buffer. `ed'
maintains a "current address" which is typically supplied to commands
as the default address when none is specified. When 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.
One exception to the rule that addresses represent line numbers is
the address `0' (zero). This means "before the first line", and is
valid wherever it makes sense.
An address range is two addresses separated either by a comma (`,')
or a semicolon (`;'). 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.
In a semicolon-delimited range, the current address (`.') is set to
the first address before the second address is calculated. This feature
can be used to set the starting line for searches.
A line address is constructed as follows:
`.'
The current line (address) in the buffer.
`$'
The last line in the buffer.
`N'
The Nth line in the buffer, where N is a number in the range `0,$'.
`+N'
The Nth next line, where N is a non-negative number.
`-N'
The Nth previous line, where N is a non-negative number.
`+'
The next line. This is equivalent to `+1' and may be repeated with
cumulative effect.
`-'
The previous line. This is equivalent to `-1' and may be repeated
with cumulative effect.
`,'
The first through last lines in the buffer. This is equivalent to
the address range `1,$'.
`;'
The current through last lines in the buffer. This is equivalent
to the address range `.,$'.
`/RE/'
The next line containing the regular expression RE. The search
wraps to the beginning of the buffer and continues down to the
current line, if necessary. `//' repeats the last search.
`?RE?'
The previous line containing the regular expression RE. The search
wraps to the end of the buffer and continues up to the current
line, if necessary. `??' repeats the last search.
`'x'
The apostrophe-x character pair addresses the line previously
marked by a `k' (mark) command, where `x' is a lower case letter
from the portable character set.
Addresses can be followed by one or more address offsets, optionally
separated by whitespace. Offsets are constructed as follows:
* A number adds the indicated number of lines to the address.
* `+' or `-' followed by a number adds or subtracts the indicated
number of lines to or from the address.
* `+' or `-' not followed by a number adds or subtracts 1 to or from
the address.
Info Catalog
(ed.info.gz) Invoking Ed
(ed.info.gz) Top
(ed.info.gz) Regular Expressions
automatically generated by
info2html