Hello everyone! This is my first question so please be kind.
I am using OSX Mountain Lion 10.8.2, running Sublime Text 2 version 2.0.1 build 2217.
Background:
In the menu bar for Sublime Text 2, when you follow “File” there is a menu option named “Close All Files”. This is by default not bound to any key binding. I am trying to bind it to “super + shift + w”. By default, “super + shift + w” is set to the menu bar item “Close Window”, which is not what I want.
What I have done so far:
The OSX System Preferences > Keyboard > Keyboard Shortcuts, added “Close All Files” bound to “super + shift + w”, and added “Close Window” which I bound to “super + alt + shift + w” (just so there was no confusion/conflict between the shortcuts).
Result: The menu bar items look correct, meaning the OSX system level “shortcuts” have been updated. However, they seem to have no effect. I suspected this was due to Sublime Text’s “keymaps”. So I removed those additions in the “Keyboard Shortcuts” section, and moved to the below trial…
I opened the Default (OSX).sublime-keymap file (by Sublime Text 2 > Preferences > Key Bindings - Default) and noticed the line:
{ "keys": "super+shift+w"], "command": "close_window" },
When I removed this line, the OSX level “binding” seemed to disappear (I am aware this should not be done in “Default” due to the updates, but I could not find a way to “overwrite” the binding to “non existent” in the User file). There was no longer a “definition” next to the command in the menu bar “File” next to the command “Close Window”, and thus… pressing “super + shift + w” no longer did the “Close Window” action. Halfway there!
Next, I needed to bind “super + shift + w” to the “Close All Files” command. I tried the obvious, which would be to add:
{ "keys": "super+shift+w"], "command": "close_all_files" },
In place of the old command… but that did not seem to do anything when I pressed the key combination. My suspicion is the command “close_all_files” does not exist, or is not “defined” in a way that Sublime Text 2 can use it.
I next tried to add the key binding to the OSX level Keyboard Shortcuts with the above left how it is. The menu bar File > Close All Files looks to be “mapped” correctly, but pressing the key combination still does nothing.
I next removed the code I had added to the Default file (above), and left the OSX system level Keyboard Shortcut in place. Success!
My Question:
I now had the shortcuts doing exactly what I want… But the problem is that I am “editing” the Default (OSX).sublime-keymap file, which is not the best idea. If I revert the Default keymap file back to it’s original state, and add:
{ "keys": "super+shift+w"], "command": "" }
to the User file… The keymap is “overwritten” but an error is thrown in the sublime console.
I am wondering if anyone knows a way I can “unbind” a Keymap in the User sublime-keymap file, so it is as if it was not written in the Default keymap file. I don’t like that every time I update Sublime Text 2, my key commands are reset - and I then have to remember to change them back using the end of the above process.
Any help would be greatly appreciated, thanks!