Wednesday, August 28, 2013

Re: Question about folding methods


On Aug 28, 2013 1:07 PM, "Niels Kobschätzki" <niels@kobschaetzki.net> wrote:
>
> 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?

Because you can't "just" select and fold and have indentation-based folds *at once*. The only way to write this is fdm=expr and you will then have to record positions by yourself since vim will not do this for you with fdm=expr.

>>
>> > 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
>  
>>
>>  
>
> --
> --
> 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/groups/opt_out.

--
--
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/groups/opt_out.

No comments:

Post a Comment