Sublime Forum

Auto-hide scrollbars

#1

Simple plugin that shows the scrollbars only when they are needed.

[code]import sublime, sublimeplugin

class toggleScrollbarPlugin(sublimeplugin.Plugin):
def onActivated(self, view):
verticalScrollBar = view.options().get(‘wantVerticalScrollBar’)
if view.size() == view.visibleRegion().size():
if verticalScrollBar:
view.options().set(‘wantVerticalScrollBar’, False)
else:
if not verticalScrollBar:
view.options().set(‘wantVerticalScrollBar’, True)[/code]
A saved a copy here: pastebin.com/z1HKNNpP

1 Like

#2

Update: Changed the triggering event from onActivated to onSelectionModified.

[code]import sublime, sublimeplugin

class toggleScrollbarPlugin(sublimeplugin.Plugin):
def onSelectionModified(self, view):
verticalScrollBar = view.options().get(‘wantVerticalScrollBar’)
if view.size() == view.visibleRegion().size():
if verticalScrollBar:
view.options().set(‘wantVerticalScrollBar’, False)
else:
if not verticalScrollBar:
view.options().set(‘wantVerticalScrollBar’, True)[/code]
And another copy can be found here: pastebin.com/ZneARMDN

1 Like

#3

Update: Changed my mind about removing onActivated.

[code]import sublime, sublimeplugin

class toggleScrollbarPlugin(sublimeplugin.Plugin):
def toggleScrollbar(self, view):
verticalScrollBar = view.options().get(‘wantVerticalScrollBar’)
if view.size() == view.visibleRegion().size():
if verticalScrollBar:
view.options().set(‘wantVerticalScrollBar’, False)
else:
if not verticalScrollBar:
view.options().set(‘wantVerticalScrollBar’, True)
def onSelectionModified(self, view):
self.toggleScrollbar(view)
def onActivated(self, view):
self.toggleScrollbar(view)[/code]
Copy: pastebin.com/mP4x04Lk

1 Like