How do I open folds one level at a time in Vim without revealing all nested folds at once?
zr
zr ("reduce" fold level) decrements the global foldlevel option by 1, opening the next layer of folds across the entire file.
19 results for "zR open all folds"
zr
zr ("reduce" fold level) decrements the global foldlevel option by 1, opening the next layer of folds across the entire file.
zr and zm
The zr and zm commands let you incrementally adjust the global fold depth across the entire buffer — one level at a time.
zR and zM
When working with a heavily folded file, manually opening or closing each fold is tedious.
zm
Instead of jumping between fully open (zR) and fully closed (zM), zm and zr let you step through fold levels one at a time.
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.
set foldlevelstart=N
When Vim opens a file with folds enabled, it uses the foldlevelstart option to decide how many fold levels to open automatically.
zO
zO (uppercase O) opens the fold under the cursor and all folds nested inside it recursively.
zMzv
The zMzv sequence collapses every fold in the file and then re-opens only the one containing your cursor.
zv
zv (view cursor) opens the minimum number of folds needed to make the current line visible — nothing more.
zO and zC
zO and zC are the recursive counterparts to zo and zc.
zx
The zx command resets and recomputes all folds in the current window based on the current foldmethod.
: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.
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.
zf{motion}
Vim supports several fold methods, but manual folding with zf gives you precise control over exactly which lines to collapse.
zi
Pressing zi in normal mode toggles the foldenable option, which controls whether folds are active in the current window.
vim.treesitter.foldexpr()
Neovim's built-in Treesitter integration includes vim.
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
:mkview 2 and :loadview 2
Vim supports up to 9 numbered view slots per file.
buffers-windows #folding #buffers-windows #navigation #config