Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you perform a command on all results of a search in Vim?

Tags:

vim

Ideally, it'd be a variation of the following:

:/somesearchstring/ norm! dd

The above searches for a string and performs a normal mode command (in this case, deleting the line). The problem is, this only performs the command on the first occurrence of the search. How do you perform an arbitrary command on the results of a search?

like image 439
voithos Avatar asked Nov 27 '25 17:11

voithos


1 Answers

Use :g like so:

:g/somesearchstring/norm! dd

or

:g/somesearchstring/d

See

:h :g
like image 161
Peter Rincker Avatar answered Nov 30 '25 07:11

Peter Rincker



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!