Sublime Forum

Textmate Snippet not working in Sublime

#1

Hey guys,

I’ve got a little problem with a important Snippet I copied form the Ruby on Rails Textmate bundle.
I think it uses regular expressions which aren’t supportet by Python. Is there a way to fix this?

<snippet> <content><![CDATA[ do${1/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1: |)/}${1:variable}${1/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/} $0 end ]]></content> <tabTrigger>do</tabTrigger> <scope>source.ruby</scope> </snippet>

Demonstration of how it does not work and how it should work: http://www.youtube.com/watch?v=E5tFx8ReMGM)

Hope someone has a neat idea for that :wink:

Regards,

Chaos

0 Likes

#2

I haven’t looked into this deeply but I suspect that Sublime doesn’t work with named capture groups (?) and \g. I would try **(whatever you’re trying to capture) **and $2, I believe, to refer to this group. But I suspect it’s a little more complex than this(?).

BTW Can’t read your video content - try using zoom :smiley:

0 Likes

#3

To refer to the current contents of a group later on, within the same pattern, use \g1 (or \g{1} ) for the first, \g2 (or \g{2} ) for the second, and so on. This is called a back-reference.

0 Likes