Sublime Forum

ST2: keyEquivalent

#1

Hi all

Has anybody had any success with getting a snippet to work without having to press TAB using keyEquivalent in a tmSnippet file??

Many thanks for any advice

Anthony

0 Likes

#2

keyEquivalent is ignored in .tmSnippet files, to get the same thing you’d have to add an explicit key binding to insert the snippet

0 Likes

#3

Please could you point me to an example of where an explicit keybinding is used to activate a Snippet.Also would this still respect the scope specified in the snippet? in my case within doublequoted strings?

Thanks

I’ve just dug around and found this for myself

To add a ruby interpolation snippet add the following into the User sublime-keymap file

[code]{ “keys”: “#”], “command”: “insert_snippet”, “args”: {“contents”: “#{${1:$TM_SELECTED_TEXT}}”}, “context”:

  { "key": "selector", "operator": "equal", "operand": "(string.quoted.double.ruby|string.interpolated.ruby) - string source" } 
  ]

}[/code]

0 Likes

#4

[quote=“aunderwo”]Please could you point me to an example of where an explicit keybinding is used to activate a Snippet.Also would this still respect the scope specified in the snippet? in my case within doublequoted strings?

Thanks

I’ve just dug around and found this for myself

To add a ruby interpolation snippet add the following into the User sublime-keymap file

[code]{ “keys”: “#”], “command”: “insert_snippet”, “args”: {“contents”: “#{${1:$TM_SELECTED_TEXT}}”}, “context”:

  { "key": "selector", "operator": "equal", "operand": "(string.quoted.double.ruby|string.interpolated.ruby) - string source" } 
  ]

}[/code][/quote]

I have been trying to add this to the default OSX sublime-keymap file in the User package. By default this file contains an empty array ]. I tried to insert the hash inside this array, but when trying to save, Sublime responds with “Error trying to parse…”. Same happens if the hash is the only content in the file. How exactly should this file end up looking in order to be parsed correcly and work with Sublime?

Also, for some reason, when I open a ruby .rb file, String interpolation such as “#{abc}” has no color coding. Anyone knows how to add this?

Thanks.

0 Likes

#5

Looks like there is some info here…

superuser.com/questions/298628/s … -shortcuts

Pasting this into the keymap file works, but I have been unable to make it work when using the “context” variable. Anyone?

0 Likes