Wednesday, February 11, 2015

Re: Can someone recommend a plugin to fold python long dict spanning over many lines?

On Wednesday, February 11, 2015 at 12:52:12 AM UTC-6, Bao Niu wrote:
> No, sorry for this abrupt assertion but indentation is no good in this case. That's why there are many plugins based on expr. Folding is simply too rigid for this job.
>
> I just want to write a wrapper function to fold those long ducts. Any thoughts?
>

Sorry for my blunder earlier, I'll try to make it up.

It looks like Python does not provide syntax folding. As Tim suggests, "indent" folding is normally recommended since Python indentation is semantic.

But others have tried making plugins for better folding, I don't know how good they are (and there may be more, these are from http://vim.wikia.com/wiki/Syntax_folding_of_Python_files#Plugins):

http://www.vim.org/scripts/script.php?script_id=2527
http://www.vim.org/scripts/script.php?script_id=515

If you write your own, you probably can use the indent() function to use the indentation of a line, except for in certain circumstances which you define. Take a look at :help fold-expr for how to write a function that defines the folding, then do a :setl foldmethod=expr foldexpr=MyPythonFoldFunction() to use it.

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