After a couple nights using eclipse to hack on tomdroid I started to wish that vim could automatically fold the global python imports like eclipse does.  As usual I just googled around hoping to find something that I could dump in my .vim/ to do that, but in this case I didn't find anything, so I had to do it myself: myfolding.vim

Some things to note:

  • It will only fold your global python imports and __all__
  • It will not fold anything over 200 lines. This is to make sure it doesn't add a significant delay when loading files, as most plugins that use fdm=expr do
  • It expects you to have at least one blank line between your global imports and your code, but why on earth would you not have that, right? ;)
  • Feedback and patches always welcome

Read more