How to unbind a key binding in Sublime Text 2?

Keyboard ShortcutsSublimetext2

Keyboard Shortcuts Problem Overview


I have a habit of hitting CTRL+T to open a new tab in ST2. However this invokes the transpose function. I could map the new_file command to CTRL+T, but is it possible to disable the command completely via user keymap file. My search suggested adding this to user keymap.

[ { "keys": ["ctrl+t"], "command": "unbound" } ]

Is the "unbound" an officially endorsed way of disabling a shortcut?

Keyboard Shortcuts Solutions


Solution 1 - Keyboard Shortcuts

{ "keys": ["ctrl+-"], "command": "noop" }

Binding a key to a no-operation or anything which wouldn't carry a command behavior, such as "hello", should work.

This would also keep the body of the binding if you change your mind in the future.

Solution 2 - Keyboard Shortcuts

I have never see or read any official documentation about the unbound command, but it works. Another option would be removing the command attribute.

{ "keys": ["ctrl+t"] }

This will also unbound a key binding.

Solution 3 - Keyboard Shortcuts

Also, if you're looking to undo a shortcut that was overridden by a plugin (I'm looking at you, "Terminal"):

  1. find your previous shortcut in Preferences -> Key Bindings (Default)
  2. Copy the line (e.g. { "keys": ["super+shift+t"], "command": "reopen_last_file" })
  3. Open Preferences -> Key Bindings (User)
  4. Add the the line in there (if the file is empty, it add [ and ] before the line, since it's an array of commands)

Solution 4 - Keyboard Shortcuts

Actually this post did help me with my issue when using ST3 on mac. Using the Package Resource Viewer you can edit the default keyboard shortcuts (Default (OSX).sublime-keymap) and delete the lines that you don't want. After doing that ST3 will no longer capture your system-wide hotkeys.

Solution 5 - Keyboard Shortcuts

The Path Tools package includes key bindings that override default Sublime key bindings which I use often, specifically: command+shift+V

On a Mac, I was able to override all of the default bindings of the Path Tools package by placing a blank file here:

~/Library/Application Support/Sublime Text 3/Packages/Path Tools/Default (OSX).sublime-keymap

I wish Sublime package installation warned users when a package includes key-bindings which will override current or default key bindings.

Solution 6 - Keyboard Shortcuts

It is possible to overwrite the default bindings of installed packages by creating a custom default bindings file.

For example I want ctrl-T to transpose, so I have modified default bindings for CTags:

  • Copy c:\Users\USER\appdata\Roaming\Sublime Text 3\Installed Packages\CTags.CTags.sublime-package to tmp.zip
  • From the zip file extract Default.sublime-keymap to c:\Users\USER\appdata\Roaming\Sublime Text 3\Packages\CTags\
  • Modify or remove the binding from this file.

If the package is updated the custom default binding file is kept, so your bindings are kept and any new bindings will have to be updated manually.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionuserView Question on Stackoverflow
Solution 1 - Keyboard ShortcutsMehradView Answer on Stackoverflow
Solution 2 - Keyboard ShortcutsRubens MariuzzoView Answer on Stackoverflow
Solution 3 - Keyboard ShortcutsfreganteView Answer on Stackoverflow
Solution 4 - Keyboard ShortcutsChad AssarehView Answer on Stackoverflow
Solution 5 - Keyboard ShortcutsBeau SmithView Answer on Stackoverflow
Solution 6 - Keyboard ShortcutsmrtnlrsnView Answer on Stackoverflow