0

After setting manual fold by indent with set foldmethod=indent, I found that seems the max indent level is around 20, i.e. more than 20 levels will collapse together.

May I know if there is a setting in vim for maximum indent level that support fold and unfold?

2
  • 1
    I find it surprising, that you would need more than 20 levels. What is the use case please? Commented Mar 14 at 12:20
  • @ChristianBrabandt a detailed c++ calltree.
    – athos
    Commented Mar 14 at 14:09

1 Answer 1

0

There is a setting, but unfortunately, 20 is the maximum supported number of nested folds. See :help 'foldnestmax':

Using more than 20 doesn't work, because the internal limit is 20.

You could try working around this by using a custom fold expression. Note that the indent() function can be used in 'foldexpr' to get the indent of a line. There may also be plugins that provide slightly different styles of indent folding. Update: Christian Brabandt points out in the comments that my interpretation of the :help was inaccurate. While the 'foldnestmax' option applies to the indent and syntax methods, the internal limit is hard coded across all fold methods.

3
  • Using foldexpression won't make you bypass the max level. It seems this level is hard coded across all fold methods. Commented Mar 14 at 12:13
  • maybe the only hack is change vim's source code then compile...
    – athos
    Commented Mar 14 at 14:09
  • 1
    I think you need to change the following line: github.com/vim/vim/blob/… Commented Mar 14 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.