Note: the question deals with only current children. I.e to close/open till current fold level, and NOT all the way as zC
, zO
, zA
, zM
, zR
.
Fold only current children recursive
zx folds: Undo manually opened and closed folds: re-apply
'foldlevel', then do "zv": View cursor line.
Also forces recomputing folds. This is useful when using
'foldexpr' and the buffer is changed in a way that results in
folds not to be updated properly.
zc close folded text
I think you want to combine both:
- go to a line in father folding level
- Press (in normal mode)
zxzc
. Or remap it: nnoremap zxc zxzc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Unfold only current children recursive
Btw:
to do the opposite, open recursive all children: zczA
Credits: https://vi.stackexchange.com/a/16046/29452
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Un-/Fold only selected recursive
Or to open/close a desired range of folds recursive:
- Select the range visually.
- :foldo (as previous link) or :foldc (as @majkinetor answer).
Tips to select the range visually:
]z jump to end of current open fold.
[z jump to beginning of current open fold.
zj moves the cursor to the next fold.
zk moves the cursor to the previous fold.
To jump through closed folds in Vim: https://stackoverflow.com/a/9407015/9391770 (I did not test it yet)