How do I open or close a fold and all its nested folds at once?
zO and zC
zO and zC are the recursive counterparts to zo and zc.
9 results for "zc close fold"
zO and zC
zO and zC are the recursive counterparts to zo and zc.
zR and zM
When working with a heavily folded file, manually opening or closing each fold is tedious.
zO
zO (uppercase O) opens the fold under the cursor and all folds nested inside it recursively.
zA
The zA command toggles the fold under the cursor together with all nested sub-folds in one keystroke.
:set foldmethod=indent
Setting foldmethod=indent tells Vim to create folds based on the indentation level of each line.
zf{motion}
Vim supports several fold methods, but manual folding with zf gives you precise control over exactly which lines to collapse.
zd
zd removes the fold definition at the cursor position — the text inside the fold is not deleted.
zj and zk
How it works When working with folded code in Vim, you often want to skip from one fold to another without unfolding anything.
:lua require('ufo').openAllFolds()
nvim-ufo is a Neovim plugin that replaces the built-in fold system with one powered by LSP (textDocument/foldingRange) or treesitter.