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'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

You must log in to answer this question.

Browse other questions tagged .