How to comment out multiple lines at once in Notepad++?
Solution 1
Select desired lines and then press CTRL+Q. This will toggle comments on and off.
Also, I've just recently become a fan of ALT + Left Mouse Click to select multiple lines and just manually comment those lines with //
.
I've found the ALT + Left Mouse Click trick to work well with Visual Studio, JetBrain products, Notepad++ but not Eclipse.
Solution 2
Also CTRL+K works well in Notepad++ to comment. If you had existing comments in a long block you are commenting, CTRL+Q will uncomment your actual comments, where CTRL+K just add another level of // in front. CTRL+SHIFT+K removes a single line comment from the selection.
Solution 3
In notepad++ I believe that the shortcut is CTRL+Q for commenting the code.
You can go to Settings > Shortcut Mapper
to change this to match your preference.
The default for a block comment is CTRL+SHIFT+Q. So you can highlight the block of code then use this shortcut.
Comments
-
030 over 1 year
In Eclipse it is possible to comment out multiple lines at once by selecting them and executing CTRL + /:
// helloworld
Is this possible in Notepad++ as well instead of typing /+/ in front of each individual line?
-
JinSnow about 6 yearsIf the shortcut aren't working to (un)comment: delete
langs.xml
and try again.
-
-
030 over 9 yearsI have created a
.html
file and executing the command results in<!-- -->
, but nothing happens in a.scala
file -
030 over 9 years
CTRL + SHIFT + Q
results in/* */
in a.java
file -
Dan Smith over 9 yearsThese are the different comments for different languages. Here is a list of supported languages natively in Notepad++: en.wikipedia.org/wiki/Notepad%2B%2B#Programming_languages
-
030 over 9 yearsThe
ALT + LMC
and subsequently//
works in.scala
as well. To uncomment:ALT + LMC
and subsequently two timesDEL
-
Patrick Szalapski over 9 yearsSo how do you uncomment in HTML?
-
Pacerier almost 9 yearsSelect multiply lines and
Ctrl+Q
is faster than multiline select and//
-
Pacerier almost 9 yearsThis is a Ctrl-Q bug actually. If there are half commented lines and half uncommented lines, Ctrl-Q should comment them all, then uncomment them all, then comment them all again.
-
030 almost 9 yearsVerified that CTRL+K works as well to comment out in Notepad++
-
malarres over 8 years"This will toggle comments on and off" as VitaminYes wrote. If you want to re-commment the commented lines, see @john-robertson 's response superuser.com/a/916881/342669
-
Jagadeesh over 7 yearsuser Ctrl+Shift+K to uncomment
-
Mohammed Noureldin about 7 yearsFor the people, with who
CTRL+Q
didn't work, you have to choose the lanuage of your file from thelanguage menu
, otherwise notepad++ will not know what is the comment type you want. -
AlainD over 3 years<kbd>Ctrl</kbd>+<kbd>Q</kbd> does not quite work as expected, though. If there is already a comment in there, the comment is un-commented. For example, select a bunch of
C++
code with one of those selected lines being// This is amazing code!
. Now that line will be converted toThis is amazing code!
. The feature is "doing what it says on the tin", just not what was expected! Personally, I'd expect that if >50% of selected lines were not commented then comment them all, and vice versa.