Sublime Forum

Issue with keybindings

#1

Hi, I’m experiencing some problems with keybindings.

The first problem has to do with ‘input shadowing’:

{ "keys": "ctrl+k"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": "ctrl+k", "ctrl+u"], "command": "upper_case" },

With this setup I’m unable to use the upper_case command, because as soon as I input ctrl+k the toggle_comment command will execute and mute any further inputs to trigger upper_case.

The second problem has to do with the parsing of .sublime-keybinding files:

{ "keys": "ctrl+k", "ctrl+u"], "command": "upper_case" },
{ "keys": "ctrl+k, ctrl+u"], "command": "upper_case" },

The first example is what’s shipped with Default (Windows).sublime-keybinding file, it works for an acquaintance (who’s using the same build) but not for me.
The second example works on for me though (but the first ctrl+k input will run toggle_command and then upper_case).

Any ideas or pro tips would be appreciated :mrgreen:

I’m using Sublime Text 2 build 2165 portable version.

0 Likes

#2

I notice that the key bindings don’t have anything assigned to Ctrl-K, presumably because of the issue you mention. Would not changing Ctrl-K (for toggle_comment) to some other combination solve the problem?

0 Likes

#3
  1. Once a key is assigned to an actual command, it cannot be used as the sequence initiator (this is just what I am going to call it). So if you want “ctrl+k” to be be used in conjunction with “ctrl+u”, “ctrl+k” can never be used as a key trigger by itself, it must always be paired as a sequence initiator.

  2. I am not entirely sure. I don’t know if issue 1 is interfering with issue 2 or not. As I understand, the keys item is always an array of strings; where each string is a single modifier+key combination. I was under the impression that “ctrl+k, ctrl+u” would not work and is bad form.

0 Likes

#4

“ctrl+k, ctrl+u”] is invalid, and will not work. You must use “ctrl+k”, “ctrl+u”].

0 Likes

#5

Makes sense, thanks facelessuser.

0 Likes