I am trying to expand a python.lang file python.lang that it highlights methods like __init__ . I tried to come up with a regex that would fit all __privateMethods() .
python.lang is an XML file containing all allocation rules for python files. Example:
<context id="special-variables" style-ref="special-variable"> <prefix>(?<![\w\.])</prefix> <keyword>self</keyword> <keyword>__name__</keyword> <keyword>__debug__</keyword> </context>
How can I expand this to match double underscores?
[SOLUTION]: What I added to my python.lang file (if anyone is interested):
First you need to add this line closer to the top where the styles are defined.
<style id="private-methods" _name="Private Methods" map-to="def:special-constant"/>
Then you add the Regex that Carles provided in his answer :
<context id="private-methods" style-ref="private-methods"> <match>(__[a-zA-Z_]*(__)?)</match> </context>
And this is what it looks like when you are done!

source share