Sublime Forum

Auto-hide tabs

#1

Auto-hides tabs panel when a single tab is present, and allows you to set a custom keybinding to toggle the tabs panel.

Feel free to test it and modify it as you see fit.

Update: Simplified it a bit, and now it works with panels correctly.

[code]# Remember to set the keybinding:

import sublime, sublimeplugin

def doToggleTabs():
show = 0
for group in range(sublime.activeWindow().numGroups()):
views = len(sublime.activeWindow().viewsInGroup(group))
if views > 1:
show = 1
break
if show == 1:
sublime.options().set(‘showTabs’, True)
else:
sublime.options().set(‘showTabs’, False)

class toggleTabs(sublimeplugin.TextCommand):
def run(self, view, args):
showTabs = sublime.options().get(‘showTabs’)
if showTabs == True:
sublime.options().set(‘showTabs’, False)
else:
sublime.options().set(‘showTabs’, True)

class toggleTabsPlugin(sublimeplugin.Plugin):
def onClose(self, view):
doToggleTabs()
def onActivated(self, view):
doToggleTabs()[/code]
A copy is saved here: pastebin.com/hB1KJSjz

0 Likes

Auto Hide tabs pluging
#2

A small followup, I cleaned the code a bit.

[code]import sublime, sublimeplugin

class doToggleTabs(sublimeplugin.TextCommand):
def run(self, view, args):
if sublime.options().get(‘showTabs’) == True:
sublime.options().set(‘showTabs’, False)
else:
sublime.options().set(‘showTabs’, True)

class toggleTabs(sublimeplugin.Plugin):
def toggleTabs(self):
for group in range(sublime.activeWindow().numGroups()):
if len(sublime.activeWindow().viewsInGroup(group)) > 1:
sublime.options().set(‘showTabs’, True)
break
else:
sublime.options().set(‘showTabs’, False)
def onClose(self, view):
self.toggleTabs()
def onActivated(self, view):
self.toggleTabs()[/code]

0 Likes