开发者

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 opene开发者_开发知识库d. 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.


It is possible not only by creating the closing marker before the opening one, but also by specifying the fold level in markers.

{{{1
    Fold you are closing.
    Inserting the closing marker below would not open the next fold.
}}}

{{{1
    Closed fold.
}}}

In this case, the fold levels helps Vim to find matching closing marker and not try one that closes the next fold.


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.


Rather than typing out the marks by hand, I tend to visually mark the reigon I want to fold with V then use zf to create the fold.

This does not open any folds that aren't open already.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜