Home Download Buy Blog Forum Support

Textmate Snippet not working in Sublime

Textmate Snippet not working in Sublime

Postby 2called-chaos on Fri Oct 05, 2012 4:04 pm

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?

Code: Select all
<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 ;-)


Regards,

Chaos
2called-chaos
 
Posts: 1
Joined: Tue Sep 25, 2012 2:18 pm

Re: Textmate Snippet not working in Sublime

Postby agibsonsw on Fri Oct 05, 2012 8:59 pm

I haven't looked into this deeply but I suspect that Sublime doesn't work with named capture groups (?<var>) and \g<var>. 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 :D
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Textmate Snippet not working in Sublime

Postby agibsonsw on Fri Oct 05, 2012 9:04 pm

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.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 23 guests