Folding
Folding hides the body of a block and shows only its first and last line, so a long file fits on one screen and you can find your way around it. Folding never edits the text: you can fold and unfold as you like.
Try it
Section titled “Try it”The steps use the sample project. The caret is the text cursor.
- Open
rtl/counter.svand click at the end of the linealways_ff @(posedge clk or negedge rst_n) begin : seq. - Press ⌘- (macOS) / Ctrl+- (Windows/Linux), or choose Code | Folding | Collapse. The body between
begin : seqandend : seqcollapses to...: the line now readsalways_ff @(posedge clk or negedge rst_n) begin : seq...end : seq. Only this block is folded; the blocks outside it stay open. (If a smaller block, such as an innerif, folded instead, the caret was inside it: press ⌘+ / Ctrl+= to expand it, click at the end of thealways_ffline (afterseq) and try again.) - Press ⌘+ (Ctrl+=) to expand it again. The file is unchanged: folding does not edit the text.
- Press ⌘⇧- (Ctrl+Shift+-) to collapse everything in the file at once, then ⌘⇧+ (Ctrl+Shift+=) to expand all. You can also click the small fold marker next to a block in the gutter (the strip beside the line numbers).
What folds
Section titled “What folds”These fold when they span more than one line:
- the bodies of modules, interfaces, programs, packages, classes, interface classes, functions, tasks, constructors, covergroups, clocking blocks, properties, sequences, checkers and user-defined primitives;
begin … end(also with a label),fork … join,case … endcase,randcase,generate … endgenerateand generate blocks;- multi-line comments, shown as
/*...*/; - the code of an inactive
`ifdefbranch (a branch the current defines switch off, greyed out; see Conditional compilation), shown as...: the directives stay visible.
A collapsed scope keeps its header and end keyword visible:
always_ff @(posedge clk or negedge rst_n) begin : seq...end : seqEmpty bodies (only blank lines) do not fold. Port and argument lists and { … } bodies (constraints, structs,
coverpoint bins) do not fold.
If it doesn’t work
Section titled “If it doesn’t work”| You see | Likely cause | What to do |
|---|---|---|
| Nothing collapses | The block is on one line, or its body is empty, or it is a kind that does not fold (a port list, a { … } body) |
Fold a block of several lines, such as the always_ff body above |
| A smaller block collapsed | The caret was inside an inner block | Put the caret on the line of the block you want |
| No fold markers or shortcuts work | The file is not a SystemVerilog file, or the plugin is disabled | See Installation |
| The shortcut does nothing | Your keymap differs, or on a laptop the key needs Fn | Use Code | Folding in the menu |