Use vi to comment out (or do something else to) several consecutive lines…

If you wanted to comment out lines 20 to 40 of a file, use the following:

:20,40s/^/# /

Use

:set number

to enable visible line numbers.

Leave a Reply