Skip to content

Comment plugin

Comment and uncomment code using the language's own comment syntax, picked automatically from the file's type. Line operations work on whole lines; block operations wrap a selection in block-comment markers.

Where to find it

Edit ▸ Comment:

Command Shortcut Acts on
Toggle Single Line Comment Ctrl+Q (⌃Q on macOS) the selected lines, or the caret's line
Single Line Comment Ctrl+K the selected lines, or the caret's line
Single Line Uncomment Ctrl+Shift+K the selected lines, or the caret's line
Block Comment Ctrl+Shift+Q (⌃⇧Q on macOS) the selected byte range
Block Uncomment the selected byte range

How it works

  • Line commands add or remove the language's line marker (e.g. //, #, --) at the start of every line the selection touches. Toggle comments the lines when any is uncommented, and uncomments otherwise.
  • Block commands wrap or unwrap the selection with the language's block markers (e.g. /* … */, <!-- … -->). Block Comment needs a non-empty selection; with nothing selected it shows a status-bar warning.

The comment markers come from the document's file type (by extension). An untitled buffer or an unknown extension falls back to C-style markers (// and /* */). If a file type has no line syntax, the line commands report "No line comment syntax known for this file"; likewise for block syntax.

Toggle is the one to remember

Ctrl+Q toggles, so you rarely need the explicit comment/uncomment commands — they exist for when you want to force one direction.