Sublime Forum

Available shortcut keys for Sublime commands

#1

There are several commands I would like to bind to keyboard shortcuts. I am not sure of the way to go in Sublime. How would I know what keys are available? I would not like to inadvertently override an important shortcut key.

0 Likes

#2

At some level, if the binding is important it’s because it’s one you use, so you probably wouldn’t pick it to use for yourself.

If you use Preferences > Key Bindings the defaults are on the left, so you can look there to see if the keys you want to use are used, and if so for what. You can also View > Show Console, enter sublime.log_commands(True), then press keys you want to use and see what they log; if anything.

1 Like

#3

Also note that due to key contexts, you can use the same key several times depending on the context.

1 Like

#4

There is a package called FindKeyConflicts which certainly works for ST3, not sure about ST(4).

Then for doing keybindings, let me point you to:

https://www.sublimetext.com/docs/key_bindings.html

https://sublime-text-unofficial-documentation.readthedocs.io/en/latest/customization/key_bindings.html

It looks a bit more complicated than it might need to be a first but once you get into it, it’s really powerful.

Here’s my keybinding (shortcut) to show the keybinding menu (for example)
(actually when i say my, I think some else came up with it, so ‘my’ as it’s in my keybinding menu)

{
 	"keys": ["ctrl+alt+shift+k"],
	"command": "edit_settings",
	"args": {
		"base_file": "${packages}/Default/Default ($platform).sublime-keymap",
		"default": "[\n\t$0\n]\n"
	}
},

and one for having a space each side of an equals sign

{ "keys": ["ctrl+alt+="], "command": "insert", "args": {"characters": " = "}},

Hopefully that’ll get you started…

1 Like