Behavior of fold when adding new fold

28 views
Skip to first unread message

Yichao Zhou

unread,
Apr 15, 2012, 3:32:09 AM4/15/12
to vim...@googlegroups.com
Hi, everyone.
I use fdm=marker. The problem is when you add a fold, the fold
after it will automatically open.

For example, type {{{<CR>}}}<ESC>zcggO{{{

You will find the second fold is opened automatically. This is
annoying when editing. Must I reclose all the folding when add a new
one?

Regards,
Yichao Zhou

Christian Brabandt

unread,
Apr 15, 2012, 4:28:52 AM4/15/12
to vim...@googlegroups.com
Hi Yichao!

Have you checked your 'foldlevel' setting?

regards,
Christian

Marcin Szamotulski

unread,
Apr 15, 2012, 5:44:19 AM4/15/12
to vim...@googlegroups.com
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

The tip is to first put closing marker }}} and then the opening one {{{.
You can also use {{{1 (without adding closing marker, the next {{{1 serves as
opening and closing marker)

Best,
Marcin

Yichao Zhou

unread,
Apr 15, 2012, 10:42:34 PM4/15/12
to vim...@googlegroups.com, Marcin Szamotulski
Unfortunately, "{{{1" has the same problem.

Ben Fritz

unread,
Apr 16, 2012, 3:06:09 PM4/16/12
to vim...@googlegroups.com

If you usually add open/close folds in the same insert operation, this will help:

http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text

If you need to move around a bunch in normal mode before adding the closing marker, it won't help as much.

Ben Fritz

unread,
Apr 16, 2012, 3:09:02 PM4/16/12
to vim...@googlegroups.com
On Sunday, April 15, 2012 2:32:09 AM UTC-5, Yichao Zhou wrote:

I realized after I posted, you should also consider using zf to create fold markers rather than going into insert mode, which should prevent this problem altogether.

:help zf

Note that the 'commentstring' option is used to determine what text to place before the created fold markers.

:help fold-create-marker
:help 'commentstring'

Reply all
Reply to author
Forward
0 new messages