Folding
Hide regions of text โ manual, syntax, indent, marker.
Folding hides ranges behind a one-line summary. Folds can be created manually (zf), or generated by syntax/indent/marker rules. zo/zc open/close, zR/zM open/close all.
Folding lets you collapse a range of lines behind a one-line summary โ useful for navigating large files or hiding boilerplate.
| Key | Action |
|---|---|
| zf{motion} | Create a fold over motion |
| zo / zc | Open / close one fold |
| zO / zC | Open / close folds recursively |
| za | Toggle this fold |
| zr / zm | Open / close one level (across all folds) |
| zR / zM | Open / close ALL folds |
| zd | Delete this fold |
| zE | Eliminate all folds |
| zj / zk | Move to next/previous fold |
Fold methods
'foldmethod' |
How folds are computed |
|---|---|
manual |
You create folds by hand with zf |
indent |
Indent depth determines fold level |
expr |
Custom Vimscript expression per line |
marker |
Folds delimited by marker strings (default {{{ and }}}) |
syntax |
Filetype's syntax file defines folds |
diff |
Auto-set in diff mode โ folds unchanged sections |
Watch
- ๐บ #0495 :mkview / :loadview โ Save Folds (not yet published)
- ๐บ #0497 g< โ Previous Output (not yet published)
See also: The {key:z} Family