Sublime Forum

Keybindings how-to

#1

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 :smile:

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:





    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?

  1. 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.

  2. 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.

  3. 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

0 Likes

#2

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

0 Likes

#3

There’s some more (unofficial) documentation here:

sublimetext.info/docs/customizat … dings.html

0 Likes

#4

Thanks, that’s really useful

Piero

0 Likes