Search code examples
vimfolding

Stopping Vim from opening all subsequent closed folds when creating a new one


I noticed that when I create a new fold (I'm using foldmethod=marker), all the folds below the one I'm creating are automatically opened. Is there a way to prevent this and leave them closed?

I can't use zf to manually create a fold because I'm editing a PHP/HTML file, and there is no 'commentstring' format good for both.


Solution

  • Try creating the }}} end marker before creating the {{{ start marker. This should prevent Vim from getting confused and opening the following folds.

    Also, if you find you accidentally open some folds, just reload the file for editing with the :e command to reset them.