Line Range

The line range specifies which lines the command should operate on. It can consist of zero, one or two line addresses. If no range is specified then it will usually default to the current line. The current line is the line your cursor is on in the text area and will typically be updated by each command to reflect the last line it operated on. Check the section on each command for the exact behavior.

The following line range forms are allowed:

<None>
No line address — this causes the command to choose a default line address. If not stated otherwise in the documentation for a command, the default for will be the current line.
line
The command will operate only on the single line number line
line1,line2
The command will operate on all lines between line1 and line2, inclusive.
line1;line2
The command will set the current line to line1, then operate on all lines between line1 and line2, inclusive.
*
This form is a synonym for 1,$, which means line 1 to the last line in the file. The command will operate on all lines.
#
The command will operate on the tagged lines in the buffer.

The elements of a line range are line addresses line and are composed of:

number
This is an ordinary line number referring to the numberth line of the buffer.
$
This special character refers to the last line of the buffer.
.
This refers to the current line of the buffer.
@
This refers to the line occupying the currently defined center line.
&
This refers to the top line of your currently displayed screen.
%
This refers to the current line if you are in the text area and line zero if you are on the command line. It is often used in macros by the Zap (z) command to operate on the command line.
/pattern/
This is the address of the line which contains an instance of the specified pattern. The search for pattern will begin at the character after the cursor and will continue to the end of the buffer. If no match has been found by that time, and option wrap is on (w+), the search will wrap around to the beginning of the buffer and continue looking for pattern from line one. If no match is found in the entire buffer then an error will be issued. This line search sets the condition register TRUE if a match is found and FALSE if a match is not found.
?pattern?
This serves as the line address of the line which contains an instance of the specified pattern. The search for pattern will begin at the character before the cursor and will go backwards through the buffer wrapping around from the first to last line if necessary. If no match is found an error will be issued as above. This line search also sets the condition register to TRUE on a match and FALSE on no match.

Each line address above may be combined with other line addresses using the + and - characters to form expressions. For example:

.-5,.+5
will specify the five lines before and after the current line.
&;.+23
will specify all lines on the current screen.
?begin?,/end/
will specify all lines between the lines containing the previous begin and the next end.

If you specify a line address which is outside the buffer you will get an error and the command will not be executed. The special character "|" can be used to limit the preceding line addresses to lie within the buffer (between one and $). This is very useful in defining macros. The | operator sets the condition register FALSE if the line address falls outside the buffer and needs to be limited. For example:

&;.+23|

is a safer form of the example shown above.