vim provides the methods foldclosed() and foldclosedend() to get the first and last line of a closed fold. The problem is: It does not respect nested folds.
For example this file:
line 1
line 2
line 3
line 4
line 5
line 6
line 7
has manual folds:
- line 1 - 6
- line 3 - 5
All of them are closed (first the second, inner, fold, then the first, outer, fold).
When calling foldclosed(4)
and foldclosedend(4)
I would expect to get the values 3
and 5
, since this is the fold line 4 is contained in. However it returns 1
and 6
for all lines except 7 (which is not in a fold).
Is there a way to get the fold state of each fold that respects nested folds? I expect something like what mkview does, which remembers the correct nested folds:
3,5fold
1,6fold
1
normal! zo
3
normal! zc
1
normal! zc