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

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.

If you know the depth 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 do zr three times to open everything back up (or 3zr!)

Full disclosure: I'm not too well versed in folds.

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.

Source Link
B Layer
  • 20.1k
  • 2
  • 32
  • 59

If you know the depth 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 do zr three times to open everything back up (or 3zr!)

Full disclosure: I'm not too well versed in folds.