Brackets, blocks and quotes
Matching pairs
Section titled “Matching pairs”When the caret is next to one element of a pair, the IDE highlights its partner. Move Caret to Matching Brace (⌃M on macOS, Ctrl+Shift+M on Windows/Linux) jumps between them.
| Kind | Pairs |
|---|---|
| Brackets | ( ), [ ], { } |
| Blocks | begin / end, fork / join, join_any, join_none |
| Case statements | case, casex, casez / endcase |
| Design elements | module / endmodule, class / endclass, package / endpackage, program / endprogram, generate / endgenerate, covergroup / endgroup |
Nested pairs match correctly (an inner begin … end does not match the outer one), and matching works in both
directions. Statements that use a keyword without opening a block are not treated as pairs: disable fork;,
wait fork; and forward declarations such as typedef class c; and typedef interface class c;.
Automatic closing
Section titled “Automatic closing”| You type | Result |
|---|---|
( before ; or at the end of a line |
() with the caret inside |
( directly before a name or expression |
only (, so you can wrap existing code |
[ or { in an empty spot |
[] or {} with the caret inside |
), ] or } right before the same closing bracket |
the caret steps over it (typing [7:0] gives [7:0], not [7:0]]) |
" in an empty spot (for example between ( and )) |
"" with the caret inside |
" directly before a word |
only " |
" right before an existing closing " |
the caret steps over it instead of inserting another quote |
Closing keywords on Enter
Section titled “Closing keywords on Enter”Press Enter at the end of a line that opens a block, and the closing keyword is added below it if it is missing. The caret is placed on the indented line in between:
always_comb begin |end| Opening line ends with | Added |
|---|---|
begin, begin : label |
end |
fork |
join |
case (…), casex (…), casez (…) |
endcase |
the header of a module, interface, program, package, class (including interface class) |
endmodule, endinterface, endprogram, endpackage, endclass |
the header of a function or task |
endfunction, endtask |
The keyword is added only when the file has fewer closing keywords of that kind than opening ones, so pressing
Enter after begin that already has its end just adds a line. Declarations without a body get nothing:
extern and pure virtual prototypes, DPI import "DPI-C" function …, typedef class c; and
virtual interface bus_if vif;. Enter in the middle of a line only splits it. One Undo removes the new line
together with the added keyword.
Try it
Section titled “Try it”- Open
rtl/counter.svand put the caret onbegininalways_ff @(posedge clk or negedge rst_n) begin : seq. The matchingend : seqis highlighted. - Press ⌃M (Ctrl+Shift+M). The caret moves to that
end. Press it again to jump back. - Put the caret on
modulein the first line.endmoduleat the bottom is highlighted. - In
rtl/top.sv, put the caret at the end of the lineinitial $display(g_lane[0].busy);, press Enter and typeinitial $displayfollowed by(. The IDE inserts(). Type": you get""with the caret between the quotes. Typehiand then": the caret steps over the closing quote. Undo your changes afterwards. - In
rtl/top.sv, put the caret at the end oflogic done;, press Enter, typealways_comb beginand press Enter. The caret is on an indented line andendis added below it.