Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

toggleTabs

By: a guest on Oct 17th, 2010  |  syntax: Python  |  size: 0.82 KB  |  views: 125  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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()