How do I open all nested folds under the cursor at once in Vim?
zO
zO (uppercase O) opens the fold under the cursor and all folds nested inside it recursively.
14 results for "zo open fold"
zO
zO (uppercase O) opens the fold under the cursor and all folds nested inside it recursively.
zO and zC
zO and zC are the recursive counterparts to zo and zc.
zf / zo / zc / za
Vim's folding system lets you collapse blocks of code into a single line, hiding the details so you can focus on the structure.
editing #editing #folding #navigation #normal-mode #productivity
zv
zv (view cursor) opens the minimum number of folds needed to make the current line visible — nothing more.
zA
The zA command toggles the fold under the cursor together with all nested sub-folds in one keystroke.
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.
zR and zM
When working with a heavily folded file, manually opening or closing each fold is tedious.
zMzv
The zMzv sequence collapses every fold in the file and then re-opens only the one containing your cursor.
:set foldmethod=indent
Setting foldmethod=indent tells Vim to create folds based on the indentation level of each line.
zx
The zx command resets and recomputes all folds in the current window based on the current foldmethod.
zd
zd removes the fold definition at the cursor position — the text inside the fold is not deleted.
zf{motion}
Vim supports several fold methods, but manual folding with zf gives you precise control over exactly which lines to collapse.
:set foldopen
The foldopen option lets you specify exactly which cursor movements and commands will automatically open a closed fold.
: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.