Monday, February 2, 2015

Re: How to preserve manually defined folds when switching to expr within a session?

Bao Niu wrote:

> I use a plugin that uses expr foldmethod. From time to time I want the
> flexibility to manually define my folds. I just switch to manual by:
> setlocal foldmethod=manual
> and all those foldlevels calculated by the expr is still there, which
> is perfect!
>
> However, when later on I want to use that expr mode to fold some newly
> added content up again, there seems no easy way. If just switch back
> by:
> setlocal foldmethod=expr
> I'd lose all my manually defined foldlevels! Is there a way to
> preserve my manually defined folds when switching back to expr?

This is not possible. When using "expr" the folds are defined by the
'foldexpr' setting. Vim evaluates that for any screen redraw, and
changing the 'foldmethod' setting forces a screen redraw.

A complicated method would be to somehow store the current folds and
have 'foldexpr' use this information to define the folds. It's not
easy, because when you insert/delete lines the position of the folds
will change.

--
hundred-and-one symptoms of being an internet addict:
163. You go outside for the fresh air (at -30 degrees) but open the
window first to hear new mail arrive.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment