range expressions can also reference lines that match a specified pattern . As with searching in other
contexts, /
is used for forward search , and ? is used for backwards searches . Use patterns
with the format:
[line]/{pattern}/
or
[line]?pattern?
where line specifies which line to start searching from (default the current line),
and {pattern} is the pattern to search for. When specified, line can be an absolute
number, or another expression that evaluates to a line number.
For example, the range of lines between the first line that matches /find/
and line 5
is given by:
:/find/,5
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
COMMAND Top 1:1
:/find/,5yank a
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
NORMAL Top 1:1
3 lines yanked into "a
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
:reg a Type Name Content l "a for, that he is unable to find anything, to let anything enter hism
As expected, Step 2 indicates that we yanked 3 lines, and Step 3 indicates that the
selection started with the line matching /find/
.
Suppose we wanted to skip a few lines of text before starting the search . For example,
if we are editing a markdown document that
contains meta information at the top of the file we may want to skip that content then
search only the body text. If we know that the meta information is 3 lines long, the
following range expression could be used:
:4/find/,$
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
COMMAND Top 1:1
:4/find/,$yank b
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
NORMAL Top 1:1
4 lines yanked into "b
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
:reg b Type Name Content l "b means: having a goal. But finding means: being free, being open, havi
Rather than starting the search from a fixed line, we can specify the starting line as a
pattern as well. This allows us to search the buffer for a specific condition, then
search for the pattern that will start the range , then proceed to the end of the range .
For example, to start from the line matching /anything/
, then search for the first
line matching /obsessed/
and include lines until the first line matching /venerable/
we could use the following:
:/anything//obsessed/,/venerable/
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
COMMAND Top 1:1
:/anything//obsessed/,/venerable/yank c
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
NORMAL Top 1:1
3 lines yanked into "c
" When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
mind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
:reg c Type Name Content l "c because he has a goal, because he is obsessed by the goal. Searching
You can also search backwards from the line containing the cursor. For example, if the
cursor is on line 4 and you want the range of lines
between the first preceding line that matches search
and the current line:
:?search?,.
"When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
m ind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
COMMAND 40% 4:1
:?search?,.yank d
"When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
m ind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
NORMAL 40% 4:1
3 lines yanked into "d
"When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
m ind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
:reg d Type Name Content l "d happen that the only thing his eyes still see is that what he searche
and finally, the range of lines between the first preceding line that matches search
and the next
line that matches venerable
:
:?search?,/venerable/
"When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
m ind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
COMMAND 40% 4:1
:?search?,/venerable/yank e
"When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
m ind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
NORMAL 40% 4:1
6 lines yanked into "e
"When· someone· is· searching,"· said· Siddhartha,· "then· it· might· easily
happen· that· the· only· thing· his· eyes· still· see· is· that· what· he· searches
for,· that· he· is· unable· to· find· anything,· to· let· anything· enter· his
m ind,· because· he· always· thinks· of· nothing· but· the· object· of· his· search,
because· he· has· a· goal,· because· he· is· obsessed· by· the· goal.· Searching
means:· having· a· goal.· But· finding· means:· being· free,· being· open,· having
no· goal.· You,· oh· venerable· one,· are· perhaps· indeed· a· searcher,· because,
striving· for· your· goal,· there· are· many· things· you· don't· see,· which· are
directly· in· front· of· your· eyes."
:reg e Type Name Content l "e happen that the only thing his eyes still see is that what he searche