Comments

From Notepad++ Wiki
Jump to: navigation, search
Managin comments in source code or otherwise interpreted text


Comments generally come in one or two flavours, depending of the programming language being considered:

  • Block comments: surround any span of text to make it invisible to the inerpreter or compiler. The text may span several lines, or just some portion of a line.
  • Single ine comments: one-sided comments marks which cause the rest of the physical source line to be hidden.

Notepad++ supports both types of comments when a language is selected and said language supports such commenting. "Language" is anything that is attached to a lexer, so it could be some source code, HTML or XML formatted data, or anything else where comenting makes sense.

Handling block comments:

  • Use Edit -> Comment/Uncomment (standard keyboard shortcut: Ctrl-Shift-Q). This surrounds the selection with the stream comment marks, when the lanuage supports them, like /* ... */ in C or Java, or <!-- ... --> in HTML.
  • For line comments:
    • Edit -> Comment/Uncomment(standard keyboard shortcut: Ctrl-K). Adds line comment mark at the beginning of each line in selection. Current line is commented if nothing is selected.
    • Edit -> Comment/Uncomment(standard keyboard shortcut: Ctrl-Shift-K). Removes line comment mark at the beginning of each line in selection.
    • Edit -> Comment/Uncomment(standard keyboard shortcut: Ctrl-Q). Adds or removes line comment mark at the beginning of each subsequent line in selection.

The "block comment" wording stems from the workaround typically used to comment a block of code when only line comments are supportd: line comment each line of the block.

Rectangular selections are supported for line commenting, but multiple selections are not - only the active selections gets operated upon.

Line ocomment marks that do not start a line are not handled at all.