The font size is controlled via the font_size
setting and this is a setting that can be applied on a per view basis. An example of that would be using Preferences > Settings - Syntax Specific
to open the settings for files of the type you’re currently editing and changing the font_size
for files of that type independently of other file types.
If you only do this occasionally, you can use the Sublime console to tweak the font size on the fly. Focus the file that you want to change, open the console with View > Show Console
and then enter view.settings().set("font_size", 20)
to change the font size and view.settings().erase("font_size")
to go back to the default.
For more generic use, you can use a plugin to provide commands that let you tweak this easily. For example, use Tools > Developer > New Plugin...
to create a stub plugin, replace it with the below, and then save the result as a .py
file in your User
package (Sublime should default to there).
import sublime
import sublime_plugin
class IncreaseLocalFontSizeCommand(sublime_plugin.TextCommand):
def run(self, edit):
current = self.view.settings().get("font_size", 10)
if current >= 36:
current += 4
elif current >= 24:
current += 2
else:
current += 1
if current > 128:
current = 128
self.view.settings().set("font_size", current)
class DecreaseLocalFontSizeCommand(sublime_plugin.TextCommand):
def run(self, edit):
current = self.view.settings().get("font_size", 10)
if current >= 40:
current -= 4
elif current >= 26:
current -= 2
else:
current -= 1
if current < 8:
current = 8
self.view.settings().set("font_size", current)
class ResetLocalFontSizeCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.settings().erase("font_size")
With that in place, you can set up key bindings for the commands. For example:
{ "keys": ["alt+ctrl+="], "command": "increase_local_font_size" },
{ "keys": ["alt+ctrl+-"], "command": "decrease_local_font_size" },
{ "keys": ["alt+ctrl+0"], "command": "reset_local_font_size" },
You could also use this plugin that provides a toggle_setting_ext
command to easily toggle between a fixed list of font sizes:
{
"keys": ["alt+ctrl+f"],
"command": "toggle_setting_ext",
"args": {
"setting": "font_size",
"options": [10, 20]
}
},
In this case you either need to include your normal font size in the list of values or use the command from above to reset it.