is used, which is 6.
*:range-pattern*
The "/" and "?" after {pattern} are required to separate the pattern from
anything that follows.
The "/" and "?" may be preceded with another address. The search starts from
there. The difference from using ';' is that the cursor isn't moved.
Examples: >
/pat1//pat2/ Find line containing "pat2" after line containing
"pat1", without moving the cursor.
7;/pat2/ Find line containing "pat2", after line 7, leaving
the cursor in line 7.
The {number} must be between 0 and the number of lines in the file. When
using a 0 (zero) this is interpreted as a 1 by most commands. Commands that
use it as a count do use it as a zero (|:tag|, |:pop|, etc). Some commands
interpret the zero as "before the first line" (|:read|, search pattern, etc).
Examples: >
.+3 three lines below the cursor
/that/+1 the line below the next line containing "that"
.,$ from current line until end of file
0;/that the first line containing "that", also matches in the
first line.
1;/that the first line after line 1 containing "that"
Some commands allow for a count after the command. This count is used as the
number of lines to be used, starting with the line given in the last line
specifier (the default is the cursor line). The commands that accept a count
are the ones that use a range but do not have a file name argument (because
a file name can also be a number). The count cannot be negative.
Examples: >
:s/x/X/g 5 substitute 'x' by 'X' in the current line and four
following lines
:23d 4 delete lines 23, 24, 25 and 26
Folds and Range
When folds are active the line numbers are rounded off to include the whole
closed fold. See |fold-behavior|.
Reverse Range *E493*
A range should have the lower line number first. If this is not the case, Vim
will ask you if it should swap the line numbers.
Backwards range given, OK to swap ~
This is not done within the global command ":g".
You can use ":silent" before a command to avoid the question, the range will
always be swapped then.
Count and Range *N:*
When giving a count before entering ":", this is translated into: >
:.,.+(count - 1)
In words: The "count" lines at and after the cursor. Example: To delete
three lines: >
3:d<CR> is translated into: .,.+2d<CR>
<
Visual Mode and Range
*v_:*
{Visual}: Starts a command-line with the Visual selected lines as a
range. The code `:'<,'>` is used for this range, which makes
it possible to select a similar line from the command-line
history for repeating a command on different Visually selected
lines.
:* *:star* *:star-visual-range*
When Visual mode was already ended, a short way to use the
Visual area for a range is `:*`.
==============================================================================
5. Ex command-line flags *ex-flags*
These flags are supported by a selection of Ex commands. They print the line
that the cursor ends up after executing the command:
l output like for |:list|
# add line number
p output like for |:print|
The flags can be combined, thus "l#" uses both a line number and |:list| style
output.
==============================================================================
6. Ex special characters *cmdline-special*
Note: These are special characters in the executed command line. If you want
to insert special things while typing you can use the CTRL-R command. For
example, "%" stands for the current file name, while CTRL-R % inserts the
current file name right away. See |c_CTRL-R|.
Note: If you want to avoid the effects of special characters in a Vim script
you may want to use |fnameescape()|. Also see |`=|.
In Ex commands, at places where a file name can be used, the following
characters have a special meaning. These can also be used in the expression
function |expand()|.
% Is replaced with the current file name. *:_%* *c_%*
# Is replaced with the alternate file name. *:_#* *c_#*
This is remembered