I'm trying to achieve a simple substitution on vim but can't get it right. I need to remove, on an entire file, all the lines that match a pattern. The pattern is "something*", meaning "something" followed by anything until the end of the line.
I tried :%s/pattern*\n//g
and :%s/pattern*$//g
without success.
Any ideas?
Cheers!
Use :g
instead of :substitute
.
:g/pattern/d
would remove all the lines that match with pattern.
As for the pattern, yours will match patter
, pattern
, patternn
and so on. Use the wildcard .
to match any characters. So your regexp should be pattern.*$
--- but if you wish to remove the lines entirely, the :g/pattern/d
does the trick fine.
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