Skip to content

Indentation

When you press Enter, the new line is indented to the level of the code around the caret. These are the places the plugin handles:

Caret is in New line
A module, interface, program, package or class body one level in
An ANSI port list module m( … ); one level in
The items of a case, fork … join, generate region or generate block (for (…) begin : g), covergroup, constraint block, property, struct or enum body one level in
A function or task body one level deeper than the function or task
A begin … end block one level deeper than the line with begin
Right after a statement header whose body is not written yet: if (…), else, for/foreach/while/repeat (…), case (…), always_ff @(…), always_comb, initial, @(…) one level deeper than the header
After the body of such a header without begin (if (a) ↵ x = 1;) or after the end of its block back to the level of the header
After endmodule, endclass, … at file level no indent

This also works while the code is incomplete, for example right after typing if (!reset) inside an always_ff block.

One level is 2 spaces by default. To change it, open Settings | Editor | Code Style | SystemVerilog and set Indent on the Tabs and Indents tab.

  1. Open rtl/top.sv from the sample project and put the caret at the end of the line logic done;.
  2. Press Enter. The caret is on a new line, indented by 2 spaces, in line with logic.
  3. Type always_ff @(posedge clk) begin and press Enter. The caret is indented by 4 spaces.
  4. Type if (!rst_n) and press Enter. The caret moves one more level in (6 spaces), ready for the body.