Skip to content

Commenting

Use comments to switch code off temporarily without deleting it, or to leave a note. A line comment (//) switches off whole lines; a block comment (/* … */) switches off part of a line, such as one statement. Both actions toggle: running them again on commented code removes the comment.

Menu action macOS Windows / Linux Result
Code | Comment with Line Comment ⌘/ Ctrl+/ Adds or removes // at the left edge of the current line, or of every selected line
Code | Comment with Block Comment ⌥⌘/ Ctrl+Shift+/ Wraps the selection in /* … */, or removes the block comment around the caret

After Comment with Line Comment the caret (the text cursor) moves to the next line, so you can comment several lines in a row by pressing the shortcut repeatedly.

Two selected lines — before
wire a;
wire b;
After Comment with Line Comment
//wire a;
//wire b;

In indented code the // is added at the left edge of the line, before the indentation: state_t state; becomes // state_t state;.

The steps use the sample project. They end with the file as it was.

  1. Open rtl/counter.sv and click on the line state_t state;.
  2. Press ⌘/ (Ctrl+/). The line becomes // state_t state; and the caret moves to the next line.
  3. Click on the commented line and press ⌘/ (Ctrl+/) again. The comment is removed: the line reads state_t state; as before.
  4. Select exactly the text assign done = is_done(state);: drag from the a of assign to just after the ;, without the leading spaces. Press ⌥⌘/ (Ctrl+Shift+/). It becomes /*assign done = is_done(state);*/.
  5. Press the same shortcut again, with the text still selected (or with the caret inside the comment). The block comment is removed and the line is back to assign done = is_done(state);.
You see Likely cause What to do
Nothing happens, or another action runs Another action uses the same shortcut (see Settings | Keymap), or your keyboard layout needs another key for / Use the menu: Code | Comment with Line Comment or Comment with Block Comment
// is not added The file is not a SystemVerilog file, or the plugin is disabled See Installation
The block comment is not removed The caret is outside the comment Click inside /* … */ first