I am trying to add a shortcut for "Close Others" tabs, but can't seem to find the command, here is what I am trying:
{ "keys": ["super+alt+w"], "command": "close_others" }
Cmd+Option+W - sort of like Cmd+Option+H in OS X, close all except the current tab, see?
Anyway, close_others
doesn't seem to do anything. I have tried close_other_windows
, close_other_tabs
, nothing works. What is the right command to do that?
And while we're on it, how do you know what commands are available? My next one will be Cmd+Option+Shift+W - "Close Tabs to the Right".
For some improvements in Sublime window management see "Close all tabs, but not the window, in Sublime Text"
Thanks!
The command is close_others_by_index
. Unfortunately, it takes arguments that cannot be passed via a simple key binding.
To make it work, you have to create a plugin. Tools/New Plugin...
:
import sublime_plugin class CloseOthersCommand(sublime_plugin.TextCommand): def run(self, edit): window = self.view.window() group_index, view_index = window.get_view_index(self.view) window.run_command("close_others_by_index", { "group": group_index, "index": view_index})
Save it in Packages/User
directory. Then you can add your key binding:
{ "keys": ["super+alt+w"], "command": "close_others" }
The same is true for "Close tabs to the right". The command is close_to_right_by_index
.
The plugin:
import sublime_plugin class CloseToRightCommand(sublime_plugin.TextCommand): def run(self, edit): window = self.view.window() group_index, view_index = window.get_view_index(self.view) window.run_command("close_to_right_by_index", { "group": group_index, "index": view_index})
The key binding:
{ "keys": ["super+alt+shift+w"], "command": "close_to_right" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With