I have the following in my vimrc:
set foldmethod=syntax
set foldnestmax=3
set nofoldenable
When I open a file, nothing is folded, as expected. The first time I close a fold using zc, it closes all possible folds recursively. Then I issue zR and it reveals them all, and then zc behaves as expected, closing one fold at a time. It appears that za behaves the same way; the first time it folds everything, every time after that it folds one thing.
Is there a way to make zc always close a single fold? I'm basically trying to eliminate the "close everything, and then reveal everything" step that I have to do any time I want to fold something.
What happens is that pressing zc will turn on folding (see :help zc
), and this will make Vim apply 'foldlevel'
which is 0 by default (meaning all folds will be closed). So if you set 'foldlevel'
to a high value in your vimrc it should work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With