Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using the following

:set foldmethod=syntax

And after I close two folds with zc

folds closed

Then proceed to write a new function, immediately after I close the block with a curly bracket } (I do this in the INSERT mode), all folds open up

enter image description here

This seems annoying, how do I stop this behaviour?

share|improve this question
Just so you know, the "create fold" command is "zf" while the "close existing fold" command is "zc". Also, when 'foldmenthod' is set to "syntax" you cannot create folds with "zf". –  Heptite Dec 21 '13 at 22:42
Sorry, I meant to say I used zc to close folds, not create them. Typo. Thanks for noticing @Heptite –  Morgan Wilde Dec 22 '13 at 9:11
[Not posted as an answer because someone might have a solution.] The problem here is that in this context Vim's folding is based on syntax rules, and when you add a new top-level {, it makes the blocks (functions) that were considered folds look like sub-blocks within your new function until you add a }, so the folds get zapped then recreated, causing them to open on you. –  Heptite Dec 23 '13 at 20:35

Your Answer


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

Browse other questions tagged or ask your own question.