Hello,
I have the following snippet which I use to create a python function:
<snippet>
<content><![CDATA[
def ${1:function}():
${0:...}
]]></content>
<scope>source.python - comment - string</scope>
<tabTrigger>def</tabTrigger>
<description>def function(): …</description>
</snippet>
Every time I type def
and press tab
, it generates:
def function():
...
I would like to make the snippet a bit more clever, and recognize (potential) class methods instead of basic functions, and produce this instead:
def function(self):
...
In order to achieve this, I think that I could check whether the current line (TM_CURRENT_LINE
) starts with a space, and then do a regex replacement, but I’m not sure how to do this.
Any suggestion?