Sublime Forum

Key bindings for a sequence with a "context"-condition

#1

Hello.

I have working user key binding for sequences, like this:

“keys”: [“alt+b”, “p”],

I also have working context-dependent bindings, e.g.:


“context”: [
{ “key”: “selector”, “operator”: “equal”, “operand”: “source.latex.tex” }
]

But together they do not work: a sequence binding with context-conditioning is ignored until I either change it to a non-sequence or remove the context clause – in both cases the behaviour becomes as expected.

What am I doing wrong?

Thanks!

0 Likes

#2

What does your full binding look like? The following works for me:

    { "keys": ["alt+b", "p"], "command": "echo",
      "context": [
        { "key": "selector", "operator": "equal", "operand": "text.tex.latex" },
      ]
    },

Are you sure that source.latex.tex is correct? I only have the one syntax for LaTeX (the built in one), for which the above binding works.

0 Likes

#3

Thank you!

“text.tex.latex” works indeed, while “source.latex.tex” seems to work for non-sequences only!
Let me check this in more detail and report back…

B.t.w., is there an updated list of all ST’s commands somewhere?
I only know this one and “echo” isn’t there (I am using “toggle_status_bar” for testing bindings & sim.).

0 Likes

#4

All right, here is the answer, apparently:

  • “text.tex.latex” is right while “source.latex.tex” is wrong (this must have been some old form, as it worked at some point);
  • the reason why my system demonstrated the behaviour I described in my first post must be some funny interplay between cashed and freshly added key assignments during those tests of mine.

The issue seems to be resolved for now, thank you very much!

1 Like

#5

The one you linked is the only public one I’m aware of; officially there is no documentation on available commands other than the default key bindings, menu files and command palette entries.

The echo command is handy for this kind of thing because it’s not destructive and only outputs to the terminal; so a good placeholder command. If you give it any arguments, it will print those too, so you can use it to test mutually exclusive key binds and the like.

0 Likes

#6

Thank you!

Let me add that the initial weird behaviour (the one I described in the first post) was, apparently, due to some interplay between format-conditioned menu entries and format-conditioned key bindings for the same commands.

0 Likes