Indentation
When you press Enter, the new line is indented to the level of the code around the caret. You never indent by hand while typing: the caret lands where the next line belongs, so the code stays consistently formatted as you write it. (To re-indent existing code, see Reformat code.) One level is 2 spaces by default.
Try it
Section titled “Try it”The steps use the sample project. The caret is the text cursor. The plugin may also
add the matching end on the line below what you type; leave it (Brackets and quotes).
- Open
rtl/top.svand click at the end of the linelogic done;. - Press Enter. The caret is on a new line, indented by 2 spaces, in line with
logic. - Type
always_ff @(posedge clk) beginand press Enter. The caret is indented by 4 spaces. - Type
if (!rst_n)and press Enter. The caret moves one more level in (6 spaces), ready for the body. - Press ⌘Z (macOS) / Ctrl+Z (Windows/Linux) until the lines you typed are gone and
rtl/top.svis as it was.
Where it indents
Section titled “Where it indents”This works while the code is incomplete, for example right after typing if (!rst_n) inside an always_ff block. These
are the places the plugin handles:
| Caret is in | New line |
|---|---|
| A module, interface, program, package or class body | one level in |
A port list written inside the parentheses after the module name, 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 one-line body of such a header without begin (the line after if (a) that holds x = 1;), or after the end of its block |
back to the level of the header |
After endmodule, endclass, … at file level |
no indent |
Changing the indent size
Section titled “Changing the indent size”Open Settings (⌘, on macOS / Ctrl+Alt+S on Windows/Linux), go to Editor | Code Style | SystemVerilog and set Indent on the Tabs and Indents tab. Reformat code uses the same setting.
If it doesn’t work
Section titled “If it doesn’t work”| You see | Likely cause | What to do |
|---|---|---|
| The new line is not indented | The file is not a SystemVerilog file (.sv, .svh, .v), or the plugin is disabled |
See Installation |
Inside code switched off by an `ifdef |
Inactive code is not analysed | See Conditional compilation |
| The indent is 4 spaces, not 2 | Indent is set to 4, or the project’s code style says so | Check Editor | Code Style | SystemVerilog | Tabs and Indents |