Hi Andrew,

Andrew Hewus Fresh writes:
> I'm sure I messed up the formatting terribly, but being able to remember
> `:.,'cs/foo/bar/` by looking in the manual would make me happy.

Yes, this is one of those useful things that's documented elsewhere but
should be in the manpage.

This is more fully documented in USD.doc/vi.ref/vi.ref, in the section
"Ex Addressing". Here's the (voluminous) text:

    Addressing in ex (and when ex commands are executed from vi) relates
    to the current line.  In general, the current line is the last line
    affected by a command.  The exact effect on the current line is
    discussed under the description of each command.  When the file
    contains no lines, the current line is zero.

    Addresses are constructed by one or more of the following methods:

    (1)  The address "." refers to the current line.

    (2)  The address "$" refers to the last line of the file.

    (3)  The address "N", where N is a positive number, refers to the
         N-th line of the file.

    (4)  The address "'<character>" or "'<character>" refers to the line
         marked with the name <character>.  (See the k or m commands for
         more information on how to mark lines.)

    (5)  A regular expression (RE) enclosed by slashes ("/") is an
         address, and it refers to the first line found by searching
         forward from the line *after* the current line toward the end
         of the file, and stopping at the first line containing a string
         matching the RE.  (The trailing slash can be omitted at the end
         of the command line.)

         If no RE is specified, i.e. the pattern is "//", the last RE
         used in any command is used in the search.

         If the extended option is set, the RE is handled as an extended
         RE, not a basic RE.  If the wrapscan option is set, the search
         wraps around to the beginning of the file and continues up to
         and including the current line, so that the entire file is
         searched.

    (6)  An RE enclosed in question marks ("?") addresses the first line
         found by searching backward from the line *preceding* the
         current line, toward the beginning of the file and stopping at
         the first line containing a string matching the RE.  (The
         trailing question mark can be omitted at the end of a command
         line.)

         If no RE is specified, i.e. the pattern is "??", the last RE
         used in any command is used in the search.

         If the extended option is set, the RE is handled as an extended
         RE, not a basic RE.  If the wrapscan option is set, the search
         wraps around from the beginning of the file to the end of the
         file and continues up to and including the current line, so
         that the entire file is searched.

         The form "\?" is accepted for historic reasons, and is
         identical to "??".

    (7)  An address followed by a plus sign ("+") or a minus sign ("-")
         followed by a number is an offset address and refers to the
         address plus (or minus) the indicated number of lines.  If the
         address is omitted, the addition or subtraction is done with
         respect to the current line.

    (8)  An address of "+" or "-" followed by a number is an offset from
         the current line.  For example, "-5" is the same as ".-5".

    (9)  An address ending with "+" or "-" has 1 added to or subtracted
         from the address, respectively.  As a consequence of this rule
         and of the previous rule, the address "-" refers to the line
         preceding the current line.  Moreover, trailing "+" and "-"
         characters have a cumulative effect.  For example, "++-++"
         refers to the current line plus 3.

    (10) A percent sign ("%") is equivalent to the address range "1,$".

    Ex commands require zero, one, or two addresses. It is an error to
    specify an address to a command which requires zero addresses.

    If the user provides more than the expected number of addresses to
    any ex command, the first addresses specified are discarded.  For
    example, "1,2,3,5"print prints lines 3 through 5, because the print
    command only takes two addresses.

    The addresses in a range are separated from each other by a comma
    (",") or a semicolon (";").  In the latter case, the current line
    (".") is set to the first address, and only then is the second
    address calculated.  This feature can be used to determine the
    starting line for forward and backward searches (see rules (5) and
    (6) above).  The second address of any two-address sequence
    corresponds to a line that follows, in the file, the line
    corresponding to the first address.  The first address must be less
    than or equal to the second address.  The first address must be
    greater than or equal to the first line of the file, and the last
    address must be less than or equal to the last line of the file.

>From that I think trailing +/-, relative line numbers, and ?? regular
expressions should be described too.

> Comments, OK?

Regarding markup: Ar should be used for things that get replaced (start,
end, c, pattern) but literal characters like . $ % should use Cm.

> +.Ar 'c

This ' should be \(aq so it doesn't become a curly quote in groff -Tpdf.

-- 
Anthony J. Bentley

Reply via email to