Brackets, blocks and quotes
These features keep blocks balanced as you type. You see which end closes which begin, you never type a closing bracket
or quote yourself, and Enter after begin writes the end. The caret is the text cursor; a highlighted partner gets
a colored background box.
Try it
Section titled “Try it”The steps use the sample project; open it and wait for indexing first.
- Open
rtl/counter.svand put the caret onbegininalways_ff @(posedge clk or negedge rst_n) begin : seq. The matchingend : seqis highlighted. - Press ⌃M (macOS) / Ctrl+Shift+M (Windows/Linux), or choose Navigate | Move Caret to Matching Brace. The caret
moves to that
end. Press it again to jump back. - In
rtl/counter.sv, put the caret onmodulein 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(). (If a suggestion list opens, ignore it or press Escape.) Type": you get""with the caret between the quotes. Typehiand then": the caret steps over the closing quote, and the line readsinitial $display("hi")(no doubled quote; the;is left out on purpose). Press ⌘Z (Ctrl+Z) until the line you added is gone. - 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. Press ⌘Z (Ctrl+Z) once: the new line and the addedendare removed together. Press it again untilalways_comb beginis gone too, so thatrtl/top.svis as it was.
If nothing is highlighted or inserted, see If it doesn’t work.
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 (a method declared without a body, such as extern function void f();), 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.
If it doesn’t work
Section titled “If it doesn’t work”| You see | Likely cause | What to do |
|---|---|---|
| Nothing is highlighted | The caret is not next to a bracket or a keyword of a pair, or the file is not a SystemVerilog file | Put the caret directly on begin, module or a bracket; see Installation |
| Brackets and quotes are not closed | The IDE’s own option is off | Check Settings (⌘, / Ctrl+Alt+S) | Editor | General | Smart Keys (the options for inserting a pair bracket and a pair quote) |
| Enter adds no closing keyword | The caret is not at the end of the line (Enter in the middle only splits it), or the file already has as many closing keywords as opening ones, or the declaration has no body | See Closing keywords on Enter |
The matching end is not highlighted |
The code is inside an inactive `ifdef branch |
See Conditional compilation |