Home Download Buy Blog Forum Support

keybindings how-to

keybindings how-to

Postby pierre on Sat Mar 19, 2011 8:52 pm

Fantastic text editor. First time I was envious
of something running only on Windows, and now you made
a version for OS X! Just...please, don't go Ogaard on us.
We are good people. We could not stand it, again :)

On to my questions. I am on Mac OS X, so some of
my woes might be system-specific, I don't know.
I'll focus on keybindings:

1) Keybinding syntax. Documentation says:
<bindings>
<binding key="ctrl+x" command="cut"/>
<binding key="ctrl+c" command="copy"/>
<binding key="ctrl+v" command="paste"/>
</bindings>
But the *.sublime-keymap files contain totally
different stuff, with entries like
{ "keys": .......
Indeed, the first syntax does not work. Anyway, I'm
fine with the second syntax, but, where is it
documented? or at least, could you give us some
advanced examples to imitate? In concrete, I was
trying a keybinding like the following one

// greek letter \alpha
{ "keys": ["a","§"], "command": "insert_snippet", "args": {"contents": "\\alpha"}, "context":
[
{"key" : "context_name", "operator" : "equal", "operand" : "text.tex.latex"}
]
}

This does not work (not surprising since the syntax
here is pure guesswork). How should I specify a latex
context for my keybinding? I know that
context : "text.tex.latex"
works, but I need a more complex set of conditions and
could not guess the correct keyword to use. Where can
I find a list of admissible keywords?

2) Is the 'Default (OSX).sublime-keymap' file the only
place where I am authorized to store keybindings?
If yes, I think it will become a huge and un-manageable
file in no time, so I hope there are alternatives.

3) Apparently, each keybinding, each snippet etc
must be specified with its own entry. Isn't there a
simpler mechanism for groups of bindings with a
similar structure? say, a command which accepts a
hash keys => substitutions, something like
[
["a"] => "\\alpha",
["b"] => "\\beta",
......
]
This would be easier to read and manage, but maybe
I'm missing something.

4) A final question on the UI colors: on the OS X version
it's virtually impossible to say the active tab from the
inactive ones, the color is too similar. Is there a way
to customize the tab colour? or, could you just make
them more different?
Same for the cursor: is its appearence customizable?

Piero
pierre
 
Posts: 28
Joined: Sat Mar 19, 2011 8:47 pm

Re: keybindings how-to

Postby pierre on Sun Mar 20, 2011 12:21 am

Answer to question 1): this works:
// greek letter \alpha
{ "keys": ["a","§"], "command": "insert_snippet", "args": {"contents": "\\alpha"}, "context":
[
{"key" : "selector", "operator" : "equal", "operand" : "text.tex.latex", "match_all": true }
]
}
so the correct keyword for scopes is "selector".
I think some more documentation (at least some advanced
usage examples) is urgently needed...

Piero
pierre
 
Posts: 28
Joined: Sat Mar 19, 2011 8:47 pm

Re: keybindings how-to

Postby guillermooo on Sun Mar 20, 2011 8:48 am

There's some more (unofficial) documentation here:

http://sublimetext.info/docs/customizat ... dings.html
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: keybindings how-to

Postby pierre on Sun Mar 20, 2011 9:27 am

Thanks, that's really useful

Piero
pierre
 
Posts: 28
Joined: Sat Mar 19, 2011 8:47 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Majestic-12 [Bot], Yahoo [Bot] and 16 guests