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.
wire a;wire b;//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;.
Try it
Section titled “Try it”The steps use the sample project. They end with the file as it was.
- Open
rtl/counter.svand click on the linestate_t state;. - Press ⌘/ (Ctrl+/). The line becomes
// state_t state;and the caret moves to the next line. - Click on the commented line and press ⌘/ (Ctrl+/) again. The comment is removed: the line reads
state_t state;as before. - Select exactly the text
assign done = is_done(state);: drag from theaofassignto just after the;, without the leading spaces. Press ⌥⌘/ (Ctrl+Shift+/). It becomes/*assign done = is_done(state);*/. - 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);.
If it doesn’t work
Section titled “If it doesn’t work”| 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 |