If you know the depthSeems that this would have a straightforward answer yet I'm not finding anything simple that accomplishes exactly what OP wants. OTOH, I'm not too well versed in folds! Anyways, here are some approximations. Maybe they'll be useful...
If you know the number of fold levels from the deepest point to the cursor you can do Nzm
where N is an integer. With your example this would be 3zm
. You'll know inner folds are close because you will need to doOpen it back up with 3zr
(or zr
three times to open everything back) Unfortunately, this starts from the deepest point in the buffer and works its way up. IOW it's not related to your cursor position!
An alternative that takes the cursor position into consideration, is to move your cursor to the deepest point of the section you want to fold, as opposed to the top of the section, and repeat zc
(orenter repeatedly or do 3zrNzc
! with appropriate N
) until you are at the point you are starting in your example.
Full disclosure: I'm not too well versed in folds. Note: I'm using syntax folding here set fdm=syntax
as opposed to indent
or other method.