I would like to comment out each line which has the following match
^.*pdf
You need to somehow consider the situation by globbing. I try to make an object of the match by brackets.
I run unsuccessfully the following commands
%s/^(.*pdf)/^%$1/
and
%s/^(.*pdf)/^(%*$1)/
and
%s/^(.*pdf)/^%\$1/
How can you comment out the matches in Vim?
I'm not sure what you exactly mean by "comment out" (are comments indicated by hashes, or what?) but it looks like what you want is to prepend a % sign. In that case,
:g/pdf/s/^/%/
should work ("on all lines containing 'pdf', change the start of the line to a %" is how you could read it).
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