Sublime Forum

Remove ctrl+left from all keybindings

#1

I want to remove ctrl+left and ctrl+right from all keybindigs in sublime. I found all mentions of these combinations in settings file and replaced them with other combinations in keymap file for user.
[
{ “keys”: [“f1”], “command”: “toggle_side_bar” },

{ "keys": ["ctrl+space+right"], "command": "next_view_in_stack" },
{ "keys": ["ctrl+space+left"], "command": "prev_view_in_stack" },

{ "keys": ["ctrl+k", "ctrl+d"], "command": "focus_neighboring_group", "args": {"forward": false} },
{ "keys": ["ctrl+k", "ctrl+d"], "command": "focus_neighboring_group" },

{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "words", "forward": false} },
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "word_ends", "forward": true} },

]
But sublime still switching tabs when i press ctrl+left or ctrl+right. What am i doing wrong?

0 Likes

#2

A command can be bound to any number of keys that you want; binding it to one key does not replace the binding that it already had, it just adds another one.

For example, if you don’t want Ctrl+1 to call focus_group, you need to do two things:

  1. Create a new binding on another key that executes that command (unless you really don’t care about the command at all)
  2. Create a binding on Ctrl+1 that does something else so that pressing that key doesn’t take the default action.

If you want to make a key combination a dead key (i.e. it just does nothing), then bind it to a command that doesn’t exist such as noop; then Sublime will silently do nothing when you press the key.

0 Likes

#3

I bound ctrl+left to commanf “nope”. As you said it made ctrl+left a dead key but it also have broken my ctrl+space+left combination. Is there any other options?

0 Likes

#4

I’m not sure that Sublime supports multiple non-modifier keys within the same key binding like that; you could say super+shift+ctrl+alt+k but not super+k+q+w for example. In that case you need to either choose a chord like is used in focus_neighboring_group or add more modifiers instead of more keys.

Note also that in your sample you have a lot of identical key bindings (for example ctrl+k appears twice). One of them is going to replace the other and so only one of them will do anything.

0 Likes

#5

Isn’t "unbound" the correct way to unbind a key. Like this?

{ "keys": ["ctrl+f4"], "command": "unbound" },
0 Likes

#6

As far as I’m aware the magic of this is that Sublime doesn’t generate any warnings or errors if a key binding invokes a command that does not exist, it just silently does nothing (except in build systems, where it generates a message to the console).

As such it doesn’t matter much what command you pick, so long as it’s something that doesn’t exist.

1 Like