Code Folding
Last updated:
Large diagrams can be difficult to navigate. Code folding lets you collapse sections of your diagram to focus on what matters.
How to Fold Code
Section titled “How to Fold Code”Look for the ⌄ icon in the editor gutter. Click it to collapse that section.
To expand a collapsed section, click the ⌃ icon that appears in its place.
Keyboard Shortcuts
Section titled “Keyboard Shortcuts”- Collapse current section:
Ctrl+NumPad-(Windows/Linux) orCmd+NumPad-(macOS) - Expand current section:
Ctrl+NumPad+(Windows/Linux) orCmd+NumPad+(macOS) - Collapse all:
Ctrl+Shift+NumPad-(Windows/Linux) orCmd+Shift+NumPad-(macOS) - Expand all:
Ctrl+Shift+NumPad+(Windows/Linux) orCmd+Shift+NumPad+(macOS)
What Can Be Folded
Section titled “What Can Be Folded”YAML frontmatter folds in every diagram type. A configuration block you’ve finished tuning collapses to a single line, keeping the diagram itself at the top of the editor.
Beyond that, the diagram types below fold their own structural blocks, whatever nests in that grammar: subgraphs in a flowchart, entity blocks in an ER diagram, loop and alt blocks in a sequence diagram.
The following diagram type support folding:
Collapsing Frontmatter by Default
Section titled “Collapsing Frontmatter by Default”If you rarely revisit a diagram’s configuration once it’s set, you can have frontmatter render as collapsed by default.
Go to Settings > Editor > General > Code Folding and enable Frontmatter under the Mermaid Studio group.