Skip to main content
2 of 2
More details and another alternative
B Layer
  • 20.1k
  • 2
  • 32
  • 59

Seems 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. Open it back up with 3zr (or zr three times) 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 (enter repeatedly or do Nzc with appropriate N) until you are at the point you are starting in your example.

Note: I'm using syntax folding here set fdm=syntax as opposed to indent or other method.

B Layer
  • 20.1k
  • 2
  • 32
  • 59