Wednesday, January 7, 2015

Re: Can I mix the use of fold-expr with fold-marker just as mixing fold-expr with fold-manual?

On Tuesday, January 6, 2015 10:16:38 PM UTC-6, Bao Niu wrote:
> Thank you very much Ben!
>
> My goal would be folding Python classes/functions automatically based on indentation, and also folding the import part at the top and some python long dict. The latter does not necessarily conform to indentation rules so marker would be ideal.
>
> The only concern about using "manual" method is once I switch to manual, can I still automatically fold up classes that are created after switching? What do pros normally do to solve this? Any hint or url would be highly appreciated. Thanks.
>
>
>


In that case, it sounds like you want to define a custom function to return a fold level, and use that as the foldexpr with foldmethod=expr.

When writing this function, the indent() function should be helpful.

Example here, plus some links and plugins: http://vim.wikia.com/wiki/Folding_for_plain_text_files_based_on_indentation

There may be better examples, that's what I could find in 5 seconds or less :-)

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