Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The first time I close a fold, it closes all folds

Tags:

vim

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.

like image 391
Robert Speicher Avatar asked Apr 26 '11 00:04

Robert Speicher


1 Answers

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.

like image 111
Jan Larres Avatar answered Oct 29 '22 09:10

Jan Larres