Sublime Forum

Custom keybinding doesn't work

#1

I changed added custom keybinding over Preferences -> Key Bindings and added following line:

{ "keys": ["ctrl+<"], "command": "toggle_comment", "args": { "block": false } },

But toggling a command doesn’t work.maybe because Sublime Text can’t handle the < (smaller then key). Please be also aware that i have a german QWERTZ keyboard.

How can I fix this?

0 Likes

Multiple caret shortcut cannot be changed in Ubuntu 22
#2

One of the answers in the linked SO question has the same advice I would give; use sublime.log_input(True) in the Sublime console, then press the key and see what gets logged.

If nothing is logged, Sublime can’t see that key or something external is stealing it. If something is logged, whatever it shows there is how Sublime sees the key and is what you should use in the binding.

0 Likes

#3

use sublime.log_input(True) in the Sublime console…

I allready did this. It shows nothing…

If nothing is logged, Sublime can’t see that key or something external is stealing it.

Normally i would buy that BUT why is ``Ctrl + <` then working in other text editors / IDEs?

Doesn’t make any sense that sublime text simply “can’t see that”…

Thx anyway

0 Likes

#4

You could install the package FindKeyConflicts to help in your investigation of the problem.

0 Likes

#5

Pressing ctrl + < yields chr evt: <0x1c> (0x1c) which is a control character (FS file separator). Any way to bind that in sublime?

0 Likes

#6

That’s a good question… I don’t think I’ve ever seen anything like that before.

JSON doesn’t support control characters in strings, so to represent it you’d need to use something like u001c to represent it. However, Sublime doesn’t seem to like that very much:

Unknown key u001c
Unable to parse binding {command: foo_bar, keys: [u001c]}

The only thing I can think of is using something external to change the keymap so that it comes across differently, which is probably fairly complicated.

1 Like

#7

It works with a preceding slash!

{ "keys": ["\u001c"], "command": ... }
1 Like

#8

Ahh sweet! I can’t believe I forgot to include that in my test. :blush:

0 Likes