Skip to content

Brackets, blocks and quotes

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

  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 (Ctrl+Shift+M). The caret moves to that end. Press it again to jump back.
  3. 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 (). Type ": you get "" with the caret between the quotes. Type hi and then ": the caret steps over the closing quote. Undo your changes afterwards.
  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.