Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

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 at 3:28
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.