Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 14 down vote accepted

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

:set foldlevelstart=99


: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
From "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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .