Guest User

toggleTabs

a guest
Oct 17th, 2010
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  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()
Add Comment
Please, Sign In to add comment