74

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?

  • If the shortcut aren't working to (un)comment: delete langs.xml and try again. – JinSnow Mar 8 '18 at 22:14
89

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.

| improve this answer | |
  • 1
    The ALT + LMC and subsequently // works in .scala as well. To uncomment: ALT + LMC and subsequently two times DEL – 030 Jul 30 '14 at 20:01
  • 1
    Select multiply lines and Ctrl+Q is faster than multiline select and // – Pacerier Jun 30 '15 at 2:57
  • 1
    "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 – malarres Sep 16 '15 at 14:20
  • 2
    For the people, with who CTRL+Qdidn't work, you have to choose the lanuage of your file from the language menu, otherwise notepad++ will not know what is the comment type you want. – Mohammed Noureldin Feb 7 '17 at 18:44
21

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.

| improve this answer | |
  • This 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. – Pacerier Jun 30 '15 at 3:09
  • 1
    Verified that CTRL+K works as well to comment out in Notepad++ – 030 Jul 18 '15 at 18:56
13

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.

| improve this answer | |
  • I have created a .html file and executing the command results in <!-- -->, but nothing happens in a .scala file – 030 Jul 30 '14 at 19:38
  • 4
    CTRL + SHIFT + Q results in /* */ in a .java file – 030 Jul 30 '14 at 19:40
  • 1
    These 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 – Dan Smith Jul 30 '14 at 19:42
  • 2
    So how do you uncomment in HTML? – Patrick Szalapski Sep 22 '14 at 13:20
  • 2
    @DanSmith, Dam I can't uncomment the commented code. What's the opposite of Ctrl-Shift-Q? – Pacerier Jun 30 '15 at 3:00
0

If you prefer only using the mouse, install the "Customize Toolbar" plugin from the plugin manager, and add "Single Line Comment" and "Single Line Uncomment" buttons.

| improve this answer | |
0

An alternative is to use a macro with a custom shortcut (CTRL+Q didn't work on javascript inside a .html document)

The trick works for a single line comment only.

Create the macro :

  1. Macro > Start recording
  2. place the cursor in your doc and type: //

  3. Macro > Stop recording

  4. Macro > Save
  5. Give a name and select your prefered keyboard shortcut.

To quickly comment a line :

Place the cursor at the beginning of the line to comment and press the shortcut you defined for the macro.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.