Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Command-line selection

Instead of using a range to focus an action, say:

5,10/booboo  <-- to find "booboo" between lines 5 and 10

or

5,10g/booboo/d  <-- to delete "booboo" between lines 5 and 10

I was wondering if I can search for the range within the command-line. (I understand the visual selection and act within that range.) All I can think of is to search for the first instance of a phrase and mark it:

:g/blahblah/mark a

Then the second instance:

:g/bleepbleep/mark b

Then perform what I want within that region:

:'a,'bg/booboo/d

I'm thinking there's a better way.

like image 780
Ricalsin Avatar asked May 28 '26 20:05

Ricalsin


1 Answers

You can do this:

:/blahblah/,/bleepbleep/g/booboo/d

You can even get a little bit more fancy and send the cursor to the top of the document first:

:0;/blahblah/,/bleepbleep/g/booboo/d

See also :help [range]

like image 62
heijp06 Avatar answered May 31 '26 09:05

heijp06



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!