With Vim, if I want to delete every line which has the text pending I can do:
:g/pending/d
How do I do this with a range? Say I want to delete every line with the text pending but only between lines 0 and 60 (or, between 0 and here) something like:
:0,./pending/d
I have searched, but I'm failing to see how to do this. I know you can do
:0,. normal <command> but I'm not sure what the normal mode command to conditionally delete a line is.
p.s. and where do you go in help to learn these things ;)
Like most if not all Ex commands, :global takes a range. So if :g/pending/d does what you want on the whole buffer it will also do what you want on the given range:
:1,.g/pending/d
As for where to find out about this, well… look no further than Vim's documentation.
:help :global says:
*:g* *:global* *E147* *E148*
:[range]g[lobal]/{pattern}/[cmd]
Execute the Ex command [cmd] (default ":p") on the
lines within [range] where {pattern} matches.
Which is pretty clear.
NOTE: lines start at 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With