SHARE
TWEET

toggleTabs

a guest Oct 17th, 2010 163 Never
  1. # Remember to set the keybinding:
  2. # <binding key="ctrl+t" command="toggleTabs"/>
  3.  
  4. import sublime, sublimeplugin
  5.  
  6. def doToggleTabs():
  7.   show = 0
  8.   for group in range(sublime.activeWindow().numGroups()):
  9.     views = len(sublime.activeWindow().viewsInGroup(group))
  10.     if views > 1:
  11.       show = 1
  12.       break
  13.   if show == 1:
  14.     sublime.options().set('showTabs', True)
  15.   else:
  16.     sublime.options().set('showTabs', False)
  17.  
  18. class toggleTabs(sublimeplugin.TextCommand):
  19.   def run(self, view, args):
  20.     showTabs = sublime.options().get('showTabs')
  21.     if showTabs == True:
  22.       sublime.options().set('showTabs', False)
  23.     else:
  24.       sublime.options().set('showTabs', True)
  25.  
  26. class toggleTabsPlugin(sublimeplugin.Plugin):
  27.   def onClose(self, view):
  28.     doToggleTabs()
  29.   def onActivated(self, view):
  30.     doToggleTabs()
RAW Paste Data
Top