Sublime Forum

key_bindings['context'] -> create custom key

#1

Hi!

Is it possible to create a custom key for context in key bindings? Something like that:

{
    "key": ["enter"],
    "command": "a_command",
    "context": [
        {
            "key": "my_custom_key",
            "operator": "equal",
            "operand": true
        }
    ]
}

I didn’t find anything, but it would be super useful.

Matt

0 Likes

#2

Yes, take a look at http://www.sublimetext.com/docs/3/api_reference.html#sublime_plugin.EventListener, in particular, on_query_context(self, view, key, operator, operand, match_all). You can define your own context and its rules.

1 Like

#3

I feel so stupid now… Sorry. But thank you :slightly_smiling:

0 Likes