Search code examples
pythonregexstringsyntax-highlightingtextmate

Differentiate syntax coloration of Python Strings vs. Docstrings in Textmate?


Love TextMate, love Python, blah, blah, blah..

But.. i hate that "Docstrings", aka multiline-comments / Sphinx's lovechild - are colored syntactically - in the same manner as normal "Strings", in my aforementioned editor of choice. Here is an example of the two types in their overly matchy-matchy outfits...

VISUAL AMBIGUITY lurking in python stringtypes in textmate

Can this slight inconvenience be regexed-away - so as to differentiate the two more easily, visually?


Solution

  • If you look at lines 560-1064 of the language part of the Python bundle, you'll find the definitions for strings. Simply, you'd find the patterns for the triple-quote strings and add another component to the capture names. Then all you need to do is add that capture name to your current style and then triple-quote strings should be colored differently.