Tuesday, October 18, 2016

How To Find out Sublime Text Key Binding Commands

I just happened to download an awesome package for Sublime Text. Unluckily, this package uses a keyboard shortcut that overwrites a default binding I really need (the CTRL + Enter command that adds a line below the current line). I therefore want to restore the normal ST behaviour and, in order to do that, I need to figure out which command was originally called when using that shortcut.

If a new package is overwriting some default binding you want to keep, but you do not know the command it was binded to, please keep reading.

NOTE: In order to make these steps work, you need to temporarily uninstall the package that is currently overwriting your key binding.

The Steps

Open Sublime Text console. To do so, you can either click on View > Show Console or use the CTRL + ` shortcut.

We can now activate the console log to show every command we run. Give the following command in the Sublime Text console:


Now press (in the appropriate context) the key sequence that you want to analyze. For example, if you want to find out the command associated with CTRL + Enter, press that sequence of keys while editing a file. In this case you will see something like the following appear in your console:

command: run_macro_file {"file": "res://Packages/Default/Add Line.sublime-macro"}

That is the command we are looking for. We can now deactivate the command logging feature before we proceed:


If you need to overwrite some package key bindings and restore the old ones, you can simply bind your old key sequence to that command. In the CTRL + Enter case, add this entry to your Default (Linux).sublime-keymap json file (Preferences > Key Bindings):

{ "keys": ["ctrl+enter"],
  "command": "run_macro_file",
  "args": {
    "file": "res://Packages/Default/Add Line.sublime-macro"

If you also want to keep your new package shortcuts, binding them to a different key binding, please refer to How To Override Sublime Text Packages Shortcuts and Preferences.


No comments:

Post a Comment