Sublime Forum

How do I bind "close other tabs" to a hotkey?

#1

close_others_by_index that is used by tab context menus failed to work for me, so I fell back to enumerating the views, activating and closing them one by one. Is there a civilized solution to this problem?

0 Likes

List of all available commands / 'Close others'-command
#2

I just wrote a quick plugin to do this.

$sublime_root/Packages/User/close_other_tabs.py

import sublime, sublime_plugin

class CloseOtherTabs(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})

keybindings


{
“keys”: “super+alt+w”],
“command”: “close_other_tabs”
}

0 Likes

#3

Thanks for the script!
Was looking exactly for that :smile:

0 Likes