Sublime Forum

Turing a # inside quotes into #{} in Ruby

#1

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

0 Likes

#2

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

{ "keys": "#"], "command": "insert_snippet", "args" : { "contents": "#{$0}" }, "context": { "key": "selector", "operator": "equal", "operand": "string.quoted.double.ruby", "match_all": true } ] },

0 Likes