Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As shown below:

enter image description here

TextMate's Python mode can't detect the end of a Python function. As a result, the folding/unfolding action isn't working for Python code.

Is this a bug of the Python bundle? If so, are there any patches to resolve this issue?

share|improve this question
up vote 3 down vote accepted

You have to make sure you undent the blank line between the function definitions, otherwise the language grammar will have trouble picking out the end of the function. It's not really a bug, just a limitation of TextMate's grammar engine and the fact that Python uses indentation to delineate blocks.

share|improve this answer
Yes, that was the reason! Thanks. – prosseek Sep 15 '10 at 23:08
Aargh. Stack Exchange won't let me change just one character: it should be dedent, or unindent, not indent. – Matthew Schinckel Apr 4 '14 at 3:28

further to mipadi's answer, if you have the textmate python bundle installed, you can select-all and use the "Cleanup Whitespace" command to automagically fix up most of the indentations in existing code so that the folding engine can find blocks.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .