Home Download Buy Blog Forum Support

Syntax Specific Key Binding

Syntax Specific Key Binding

Postby erinata on Thu Apr 12, 2012 3:14 pm

I see that there is no syntax specific key binding in the preference choice....

But can I specify syntax selector in key binding?

Say, can I do something like
Code: Select all
"keys": ["tab"], "command": "bullet_indent", "context":
[
{
"key": "selector", "operator": "equal", "operand": "source.markdown"
}
]


So that the key is only bind when the file opened is a markdown file?
erinata
 
Posts: 29
Joined: Wed Jan 25, 2012 12:19 pm

Re: Syntax Specific Key Binding

Postby quodlibet on Thu Apr 12, 2012 5:08 pm

You're pretty close. I think the following should work:

{
"keys": ["tab"], "command": "bullet_indent", "context":
[{ "key": "selector", "operator": "equal", "operand": "text.html.markdown" }]
},


(I wrapped it up in squiggly brackets and a comma,with the assumption that it's not the last binding in the file; I also modified the scope.)

You can also use more specific scopes, such as "meta.paragraph.list.markdown" or "markup.list.unnumbered.markdown". (I use the ScopeHunter plugin to determine scopes.)

Alex
quodlibet
 
Posts: 553
Joined: Sat Jun 18, 2011 5:53 pm

Re: Syntax Specific Key Binding

Postby erinata on Thu Apr 12, 2012 5:36 pm

oh thanks soooooo much!!!!!!!!!!!!

actually I didn't make mistake in the text.html.markdown part (I type it wrong when I post in the forum)

But I screw up the braces =_=.................

Thanks for telling me that it works so that I didn't give up and think that Sublime Text do not allow me to do it.........:P
erinata
 
Posts: 29
Joined: Wed Jan 25, 2012 12:19 pm


Return to Plugin Development

Who is online

Users browsing this forum: Majestic-12 [Bot] and 6 guests