How to enable block lock for Python comments in TextMate?

In TextMate 1.5.10 r1623 you get small arrows that allow you to reset method blocks:

alt text

Unfortunately, if you have a multi-line Python comment, it will not recognize it, so you cannot flush it:

def foo(): """ How do I fold these comments? """ print "bar" 

TextMate has this on its website on how to set up folding: http://manual.macromates.com/en/navigation_overview#customizing_foldings

... but I'm not good enough in regular expression to do anything. TextMate uses the Oniguruma regex API, and I use Python.tmbundle by default, updated to the latest version through GetBundles.

Does anyone have an idea on how to do this? Thanks in advance for your help! :)


Adding regex default values foldingStartMarker and foldingStopMarker for Python.tmbundle under the Python language in the package editor:

 foldingStartMarker = '^\s*(def|class)\s+([.a-zA-Z0-9_ <]+)\s*(\((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")'; foldingStopMarker = '^\s*$|^\s*\}|^\s*\]|^\s*\)|^\s*"""\s*$'; 
+4
source share
2 answers

According to this Textmate mailing list thread , if you follow it to the end, proper code coding for Python is not supported. In principle, regular expressions implemented in foldingStartMarker and foldingStopMarker do not allow capturing, therefore the number of intervals at the beginning of the “final fold” cannot be compared with the “start of dumping”.

The question is not final and not officially addressed by the creator of Textmate, Allan Odgaard; however, since the thread has been from 2005, I assume this is a dead issue, not one that will be supported.

+1
source

It seems like multi-line addition of comments works in TextMate, but you should align your quotes just like this:

 """ Some sort of multi line comment, which needs quotes in just the right places to work. """ 

It looks like this:

enter image description here

enter image description here

+2
source

Source: https://habr.com/ru/post/1334794/


All Articles