52

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?

user
  • 17,781
  • 20
  • 98
  • 124
  • 1
    The official documentation is here: http://docs.sublimetext.info/en/latest/reference/key_bindings.html As of this writing, it makes no mention of unbinding. – David J. Dec 16 '13 at 20:59
  • thanks I really needed that `super+forward_slash` unbound! I use it to search in the menu bar in all apps. – Rivenfall Feb 03 '16 at 00:08

6 Answers6

26

{ "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.

Mehrad
  • 4,093
  • 4
  • 43
  • 61
22

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.

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
  • If I type any gibberish instead of "unbound", it has the same effect. I'm curious about the 'correct' way of doing it... Do you have a documented / official source for your second method? I don't think it works. – user Oct 08 '13 at 17:45
  • This is mentioned on the Sublime UserEcho forum: http://sublimetext.userecho.com/topic/89378-support-unbinding-of-keys/ – David J. Dec 16 '13 at 20:56
  • 9
    It seems as though if a key combo is defined in my default keybindings, but I want to unbind it in my user bindings, omitting "command" does not work, but setting "command": "unbound" does. – amacleod Mar 12 '14 at 21:06
  • I hit ctrl+T too many times when I want to 'redo', completely destroying the 'redo-history', so I bound this: { "keys": ["ctrl+t"], "command": "redo_or_repeat" } – TrySpace May 19 '14 at 13:47
  • Yep, in the user bindings only setting command to unbound works for me. Simply omitting the command does no change. – Svish Sep 26 '14 at 17:37
  • At least in my Sublime Text 3 on Mac OS X, this does not seem to work, I get an error about not being able to parse the key binding. Mapping to `"command": "unbound"` does work. – Martin Probst May 19 '15 at 15:33
  • 1
    +1 Worked for me to remove a keybinding defined in the default keybindings file from the user keybindings file. Using Sublime Text 3 build 3095 (Dev Channel),OSX 10.10.4. The "command": "unbound" or "command": "noop" solution was swallowing the shortcut used for an external application (clipboard manager) – Jay Jul 11 '15 at 03:55
15

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)
fregante
  • 29,050
  • 14
  • 119
  • 159
  • 5
    +1 for the Terminal diss. Side note, it's `{ "keys": ["ctrl+shift+t"], "command": "reopen_last_file" }` for Windows users. – dcastro Jan 05 '17 at 14:02
  • 5
    Came here exactly for the same reason (Terminal). So there is no convenient way to get the original shortcut back other than copying it? Thanks anyway! – sylbru Feb 05 '18 at 12:46
6

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.

Chad Assareh
  • 61
  • 1
  • 2
5

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.

Beau Smith
  • 33,433
  • 13
  • 94
  • 101
  • 2
    Yay! The Path Tools author (pjdietz) has since removed the conflicting key bindings: https://github.com/pjdietz/sublime-path-tools/commit/8208974e0410aac4221b0cb4f6b0e63a70477e28 https://github.com/pjdietz/sublime-path-tools/commit/ff4674d95b3664018fc2d924f95dc384293be27e https://github.com/pjdietz/sublime-path-tools/commit/e8e7ad9fc255fa945f78cd11e780ed1b95ace656?diff=split – Beau Smith May 09 '16 at 18:17
3

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.

mrtnlrsn
  • 1,105
  • 11
  • 19
  • 2
    A quick and convenient way to do this is using the `PackageResourceViewer` package. Run command "open resource" then select the guilty package then open the keymap file and edit it as you wish. This avoids having to navigate to the correct file. – asachet Sep 23 '16 at 13:48