Search code examples
vimfolding

Vim disable autofold when I scroll down?


I have folding enabled in vim, here is .vimrc snipet.

set foldmethod=syntax
set foldnestmax=1
set foldlevel=0
set foldclose=all

It works fine, but when I scroll down a c-function it automatically folds, any idea on how to leave the fold open?


Solution

  • Vim is just doing what you've instructed it to do; especially with your chosen combination of 'foldclose' and 'foldlevel'. From :help 'foldclose':

    'foldclose' 'fcl'   string (default "")
            When set to "all", a fold is closed when the cursor isn't in it and
            its level is higher than 'foldlevel'.  Useful if you want folds to
            automatically close when moving out of them.
    

    Simply drop the set foldclose=all if you don't like that behavior.