Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I really like the folding in Vim, but there are a couple non-file buffers (command-t plugin's window for one) that I really don't want it folding, as the normal fold commands don't work there.

If I could just tell vim to not automatically close folds (only close them when I tell it to) that should fix the problem, but I'm not seeing any options in the vim help for changing that behavior. Is there a way to have folding enabled but not automatically close all folds when a buffer is created/file opened?

share|improve this question

3 Answers 3

up vote 11 down vote accepted

The command to have no folds closed when a buffer is opened is

:set foldlevelstart=99

See

:help foldlevelstart

for more.

share|improve this answer
    
that looks like what I want. –  Herms Jul 30 '10 at 20:17

you can do:

set nofoldenable

for example in my .vimrc I have:

set foldmethod=indent       " automatically fold by indent level
set nofoldenable            " ... but have folds open by default
share|improve this answer
2  
From tech.groups.yahoo.com/group/vim/message/119298: "With nofoldenable, all folds are open, as if they did not exist at all. You cannot interact with them. But, as soon as you try interacting with them (by pressing zc for example) you automatically set foldenable, which will apply all the folds that exist in the window." –  Mansoor Siddiqui Aug 6 '11 at 18:35

zR is the command to open all folds. I assume you could use vim's autocommand (au) to just put an option in your .vimrc to issue the command zR when opening a buffer with the file extensions you don't want started up with automatic closing of folds. Something like this:

au BufRead *.myext zR

haven't tested, actually correct syntax may be use exe command for the zR:

au BufRead *.myext exe "zR"

I'm assuming you're talking about autofolding of manually-defined or automatically defined folds when a buffer is opened. If the buffers in questions are not supposed to have folds at all, then it's probably a different issue, something where you want to have folding disabled for those buffer types.

share|improve this answer
    
yea, but zR doesn't work when I'm in the buffer, so I'm not sure if the automatic command would work. –  Herms Jul 30 '10 at 20:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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