Skip to content

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.

The steps use the sample project; open it and wait for indexing first.

  1. Open rtl/counter.sv and put the caret on begin in always_ff @(posedge clk or negedge rst_n) begin : seq. The matching end : seq is highlighted.
  2. 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.
  3. In rtl/counter.sv, put the caret on module in the first line. endmodule at the bottom is highlighted.
  4. In rtl/top.sv, put the caret at the end of the line initial $display(g_lane[0].busy);, press Enter and type initial $display followed by (. The IDE inserts (). (If a suggestion list opens, ignore it or press Escape.) Type ": you get "" with the caret between the quotes. Type hi and then ": the caret steps over the closing quote, and the line reads initial $display("hi") (no doubled quote; the ; is left out on purpose). Press ⌘Z (Ctrl+Z) until the line you added is gone.
  5. In rtl/top.sv, put the caret at the end of logic done;, press Enter, type always_comb begin and press Enter. The caret is on an indented line and end is added below it. Press ⌘Z (Ctrl+Z) once: the new line and the added end are removed together. Press it again until always_comb begin is gone too, so that rtl/top.sv is as it was.

If nothing is highlighted or inserted, see If it doesn’t work.

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;.

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

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:

Type always_comb begin and press Enter
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.

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