Home Download Buy Blog Forum Support

Turing a # inside quotes into #{} in Ruby

Turing a # inside quotes into #{} in Ruby

Postby jlippiner on Mon Dec 05, 2011 12:05 am

I LOVE ST but I keep running into this one annoying thing coming from TextMate. When Im doing text injection in HAML, ERB or Ruby I'm so used to # expanding to #{} that it trips me up.

For example, in Ruby or Ruby HAML if I did this

= "Hello #{@user.name}," then it will inject the user name correctly.

In TextMate if I entered # inside quotes it would auto change it to #{CURSOR_HERE}. Does anyone know how I could do this in ST?

Thx,

Josh
jlippiner
 
Posts: 4
Joined: Sun Nov 20, 2011 12:28 pm

Re: Turing a # inside quotes into #{} in Ruby

Postby C0D312 on Mon Dec 05, 2011 2:51 am

In your user keybindings file, you can add something like this:

Code: Select all
{
      "keys": ["#"],
      "command": "insert_snippet", "args" : { "contents": "#{$0}" },
      "context":[
         { "key": "selector", "operator": "equal", "operand": "string.quoted.double.ruby", "match_all": true }
      ]
   },
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 23 guests