Wednesday, August 28, 2013

Re: Question about folding methods

On Tue, Aug 27, 2013, at 22:17, Nikolay Pavlov wrote:


On Aug 28, 2013 12:01 AM, "Niels Kobschätzki" <niels@kobschaetzki.net> wrote:
>
> Hi,
>
> I have a question about folding methods. Out of my head there are 3: syntax, indent, manual.

You missed diff, marker and expr.

> When I set the mode to one of the "automatic" ones (syntax, indent), it doesn't seem that I can zf anymore. I tried to switch to manual (:set foldmethod=manual), set the fold manually and then switch back to indent but then my manual fold got opened again.

> Is there any way to be in indent mode because then I can easily use "zc" and also use "zf" when I want to fold outside the indentations?

You can remap zf to use custom function and emulate any behavior you need with fdm=expr. I guess you will have to rely on something like markers or signs to achieve what you want since simply recording first and last lines in a custom function and use this data within foldexpr will not work as when lines are added/removed simple records become invalid. Sign and markers position gets adjusted in this case though.

Tbh I have no real idea what you are talking about ;)
I just would like to select in visual mode some lines and fold them. Why should I record anything?
 

> Is there a faster way to switch between folding methods than ":set foldmethod=<method>"?

As usual, you should create a custom mapping.

I thought so but hoped for something built-in.
 
Thanks for your help :)
 
Niels
 
 

No comments: