Skip to main content
Code folding ships in 0.14.0 and later. Update to the latest release to get it — see Installation.
Folding collapses a region of a buffer down to its header line so you can hide a function body, a block, or a run of imports while you work elsewhere. Vorto follows Vim’s z fold keys, and figures out where the foldable regions are for you — no markers to add by hand.

Fold keys

A closed fold keeps its header row visible and hides the rows beneath it, drawing a ⋯ N lines marker that tells you how many lines are tucked away. Vertical motions (j / k, Ctrl-d, search, and the rest) step over the hidden lines, and the cursor is never left stranded inside a closed fold.

Where folds come from

Vorto works out the foldable regions in a buffer from three sources, in order of preference:
  • Tree-sitter folds.scm. When the buffer’s language ships a folds.scm query, its @fold captures define the fold ranges — function bodies, blocks, arrays, and whatever else the query marks.
  • Indentation fallback. For a language without a folds.scm (or a buffer with no grammar at all), Vorto derives folds from indentation, so folding still works in any file.
  • Import runs. Consecutive import / use statements at the top of a file fold together as a single region, including the multiline brace and paren forms, so you can collapse a long import block in one keystroke.

Per-pane fold state

Which folds are open or closed is tracked per pane and follows the buffer: switch away to another buffer and back, and your folds are exactly as you left them. Splitting a pane copies its fold state into the new pane, and the state is cleaned up when you close the buffer (:bd) or reload it from disk (:reload).

Theming the fold marker

The ⋯ N lines marker drawn on a closed fold’s header row is painted with the ui.fold theme scope. Set it in your theme to control the marker’s color — see Themes.

See also

Keybindings

The full default keymap, including the fold keys.

Grammars

How folds.scm and the other tree-sitter query files work.