Sample Header Ad - 728x90

How to comment multiple lines at once?

153 votes
6 answers
414254 views
How can I select a bunch of text and comment it all out? Currently I go to the first line, go to insert mode then type # left-arrowdown-arrow and then I repeat that sequence, perhaps saving a few keystrokes by using the . repeat feature to do each line. Is there anyway I could (for instance) select either multiple lines in visual mode or by using a range of lines and an ex ('colon') command and for that range comment out all the lines with a # to make them a "block comment". The ability to quickly 'de-comment' (remove the #'s) for a block comment would also be nice.
Asked by Michael Durrant (43563 rep)
Mar 20, 2014, 04:14 PM
Last activity: Apr 25, 2023, 10:24 AM