Home Download Buy Blog Forum Support

ST2: keyEquivalent

ST2: keyEquivalent

Postby aunderwo on Thu Sep 08, 2011 9:50 am

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
aunderwo
 
Posts: 7
Joined: Thu Sep 08, 2011 9:40 am

Re: ST2: keyEquivalent

Postby jps on Thu Sep 08, 2011 10:57 am

keyEquivalent is ignored in .tmSnippet files, to get the same thing you'd have to add an explicit key binding to insert the snippet
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: ST2: keyEquivalent

Postby aunderwo on Thu Sep 08, 2011 3:16 pm

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: Select all
{ "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" }

      ]
}
aunderwo
 
Posts: 7
Joined: Thu Sep 08, 2011 9:40 am

Re: ST2: keyEquivalent

Postby kmandrup on Wed Sep 28, 2011 2:37 pm

aunderwo wrote: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: Select all
{ "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" }

      ]
}


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.
kmandrup
 
Posts: 4
Joined: Wed Sep 28, 2011 2:31 pm

Re: ST2: keyEquivalent

Postby kmandrup on Wed Sep 28, 2011 2:45 pm

Looks like there is some info here...

http://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?
kmandrup
 
Posts: 4
Joined: Wed Sep 28, 2011 2:31 pm


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 16 guests