Commenting code in Notepad++

CommentsNotepad++

Comments Problem Overview


I'm using Notepad++ as an editor to write programs in Python. It might sound daft but I looked around in the editor and could not find any means (not the manual way but something like in Emacs) to do a block comment in my code.

Since so many language settings are supported in Notepad++, I'm curious to find a way to block comment code.

Comments Solutions


Solution 1 - Comments

CTRL+Q Block comment/uncomment.

See Keyboard And Mouse Shortcuts - Notepad++ Wiki.

Solution 2 - Comments

Try the following shortcut:

Ctrl+K.

Solution 3 - Comments

This link was exactly what I was searching for .

Let me summarize the answers for others' benefit (for python and notepad++)

  1. Ctrl+K on multiple lines (i.e. selected region) allows you to block comment.

Also note that pressing the combination multiple times allows you to add multiple "#"s (sometimes I use that while testing to differentiate from other comments)

  1. Ctrl+Shift+K (on the commented region) allows you to perform block uncomment

  2. Ctrl+Shift+K on an uncommented selected region does not comment it

  3. Ctrl+Q allows you to block comment/uncomment in a toggled mode (meaning, you cannot add multiple '#'s like in 1) )

Hope this helps another wandering soul.

Question - how would you develop a hack of keyboard combinations to comment/uncomment if there were no shortcuts? Just curious. I've no clue hence asking.

Solution 4 - Comments

Yes in Notepad++ you can do that!

Some hotkeys regarding comments:

  • Ctrl+Q Toggle block comment
  • Ctrl+K Block comment
  • Ctrl+Shift+K Block uncomment
  • Ctrl+Shift+Q Stream comment

Source: shortcutworld.com from the Comment / uncomment section.

On the link you will find many other useful shortcuts too.

Solution 5 - Comments

for .sql files Ctrl+K or Ctrl+Q does not work.

to insert comments in .sql files in Notepad++ try Ctrl+Shift+Q

(there is no shortcut to uncomment the code block though. I have tried that on v5.8.2 )

Solution 6 - Comments

Use shortcut: Ctrl+Q. You can customize in Settings

Solution 7 - Comments

In your n++ editor, you can go to Setting > Shortcut mapper and find all shortcut information as well as you can edit them :)

Solution 8 - Comments

Two ways for block commenting:

  1. Ctrl+Shift+Q

or

  1. Select the block
  2. Alt + Right click
  3. Choose block comment.

Solution 9 - Comments

Without having selected a language type for your file there are no styles defined. Comment and block comment are language specific style preferences. If that's a PITA...

To select for multi-line editing you can use

shift + alt + down arrow

Solution 10 - Comments

To add a comment under any code on NOTEPAD++ first we have to save and define the programming or scripting file type. Like, save the file as xml, html etc. Once the file is saved in proper format you will be able to add a comment directly using the shortcut ctrl+Q

Solution 11 - Comments

Just select the desired line and click on Ctrl + Q Ps: I am using Notepad++

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArnkrishnView Question on Stackoverflow
Solution 1 - CommentsNiels R.View Answer on Stackoverflow
Solution 2 - CommentsJavierView Answer on Stackoverflow
Solution 3 - CommentsRaajView Answer on Stackoverflow
Solution 4 - Commentsuser3898160View Answer on Stackoverflow
Solution 5 - CommentsN30View Answer on Stackoverflow
Solution 6 - Commentsuser3402702View Answer on Stackoverflow
Solution 7 - CommentsMasud ShrabonView Answer on Stackoverflow
Solution 8 - CommentsMaheshView Answer on Stackoverflow
Solution 9 - CommentsKickahaView Answer on Stackoverflow
Solution 10 - CommentsVijay ParchaniView Answer on Stackoverflow
Solution 11 - CommentsIkbelView Answer on Stackoverflow