Sublime Forum

How do I reclaim default keymaps hijacked by extensions?

#1

Many extensions provide their own keymaps which might overlap either with other extension keymaps or (even worse) with the default ones. In my case the otherwise excellent MarkdownEditing extension hijacks Ctrl+1 to set header levels instead of leaving it to focus the view to the first group.

I’ve tried setting the hijacked keymap to an empty string hoping that it would “release” it but that doesn’t work.

Currently I’m overcoming this by finding the original hijacked keymaps in ST’s default .sublime-keymap and copying them in my user .sublime-keymap. Essentially I’m redefining every hijacked keymap. It’s a nasty hack of duplication and I don’t like it.

Do you guys & gals have any idea if I can do it in a cleaner way?

0 Likes

#2

In terms of identifying hijacked keymaps, you can try FindKeyConflicts. In terms of restoring the default behavior, you have a couple of options. The first is to copy the key binding entry to your user folder, as you are already doing. The second is to override the keymap file itself for the plugin. If you are using ST3, this can be done by creating a file with the same package structure and name in the Packages folder. To make doing that easier, you can use PackageResourceViewer. Simply run the command via the command palette by searching for “PackageResourceViewer: Open Resource”. Select the key map file, make your modification, and save. It will place the file in the proper location. You can do the same with ST2, I’m just unsure how package control handles modified files when upgrading a package. It may be okay too, I just haven’t investigated. The most full proof solution is to move your bindings to the user folder. However, then you might “hide” functionality that other plugins bring with the same bindings under a different context. You could also ask the package developer to add a context to the key bindings, perhaps making them togglable.

0 Likes