Sublime Forum

Zoom plugin

#1

i made zoom out/in plugin which actually increase/decrease the current font size.
if you want just make a new file named: Zoom.py under %appdata%\Sublime Text\Packages\User, which contains:

[code]import sublime, sublimeplugin

class ZoomInCommand(sublimeplugin.TextCommand):
def run(self, view, args):
current_font = view.options().get(‘font’)
(font, sep, size) = current_font.rpartition(" ")
new_size = int(size) + 1
new_font = font + " " + str(new_size)
view.options().set(‘font’, new_font)
print "set new font to: " + new_font

def isEnabled(self, view, args):
return True

class ZoomOutCommand(sublimeplugin.TextCommand):
def run(self, view, args):
current_font = view.options().get(‘font’)
(font, sep, size) = current_font.rpartition(" ")
new_size = int(size) - 1
new_font = font + " " + str(new_size)
view.options().set(‘font’, new_font)
print "set new font to: " + new_font

def isEnabled(self, view, args):
return True[/code]

also add key binding on Default.sublime-keymap under %appdata%\Sublime Text\Packages\User

<bindings> ... <binding key="ctrl+equals" command="zoomIn"/> <binding key="ctrl+minus" command="zoomOut"/> ... </bindings>

after that pressing control and plus or minus next to the backspace will do the trick(not the keypad :unamused: )

0 Likes

#2

Someone else already posted a similar plug-in: https://forum.sublimetext.com/t/font-size-resizing/52/1

It also also has a ctrl-0 shortcut that returns the font size to the default.

I wonder, is there a way to bind a command to ctrl-mousewheel up/down?

0 Likes

#3

Mouse buttons aren’t yet bindable, no - has been requested before though.

0 Likes

#4

vim: thanks for good work! So now Sublime have something like Intellipad’s font resizing. Though not so smooth and cool, it does its work.
One problem, though: it will happily zoom out font to size < 0. When it happens, font size jumps to some standard value, and then changes to small size when zooming in.

0 Likes