I've the following content:
group1
item1
item2
item3
group2
item4
item5
group3
item6
where I'd like to select all items which belong to group2
using a search range.
Here is my approach:
:/group2\n\zs/;,/^\ze\S/p
however it seems the \ze
doesn't take any effect, because this is what is printed:
item4
item5
group3
I expect only item4
and item5
to be printed, without ending pattern (group3
).
How do I exclude the ending pattern then?
,
is redundant btw. You could get the effect you want by changing^
to\n
in the second pattern, but you might be better off with offsets (e.g.:/^group2/+;/^group/-p
) as noted in the accepted answer.