Stop VIM from opening all subsequent closed folds when creating a new

I noticed that when I create a new fold (I use foldmethod=marker ), all the folds below what I create automatically open, is there a way to prevent this and leave them closed?

I cannot use zf to manually create a fold because I am editing PHP / HTML and there is no 'commentstring' format suitable for both.

+4
source share
3 answers

Try creating an end marker (" }}} ") before by creating a start marker (" {{{ "). This should prevent vim from getting confused and open the following folds.

Also, if you find that you accidentally opened several folds, simply edit the file (" :e ") to reset.

+1
source

This is possible not only by creating a closing marker before opening, but also by indicating the level of addition in the 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 level helps Vim find the appropriate closing marker, rather than trying the one that closes the next fold.

+3
source

Instead of printing labels manually, I tend to visually mark the reigon, which I want to reset with V , and then use zf to create a crease.

This does not open any folds that are not yet open.

0
source

Source: https://habr.com/ru/post/1299434/


All Articles