I love working with Sublime Text, but one of its features annoys me sometimes which is "the accidental zoom in"
. Whenever that happens it breaks the momentum and I have to change it back to where it was and is kind of annoying. I searched for a shortcut which can reset the size back to normal but each one of them involved creating a python file and it does not work for me for some reason.
What would made my life much easier that if I could just change something in Preference.sublime-settings
file and reset the font back to where I wanted it to be with just a shortcut key say "Control+0"
.
To increase the font size, press Ctrl + ] . (Press and hold the Ctrl , then press the right bracket key.) To decrease the font size, press Ctrl + [ .
If you want to change the font size then simply follow. Preferences-> Default File preferences. After find Font properties like font Courier New 12 we (recommend to use CTRL+F) then change size of it. Click save and instantly you can see the changes.
Hold down the Ctrl and press the + to increase the font size or - to decrease the font size. Pressing either of these keys while continuing to hold down the control key continues to increase or decrease the font until it reaches its maximum. To reset the font back to the default size press Ctrl + 0 (zero).
For background, Sublime Text 3 has commands named increase_font_size
and decrease_font_size
. These commands modify the font size up or down by some value (depending on what it is currently set to) and then directly modify the setting in the Preferences.sublime-settings
file, which makes the change permanent everywhere.
These commands are bound by default to Ctrl+WheelUp/Down as well as Ctrl++ and Ctrl+-.
There exists a command reset_font_size
(not bound to a key by default), but this command works by erasing the font size setting entirely; thus if you weren't using the default font size, this is unlikely to be useful. Additionally, this would also not reset any e.g. syntax specific font size.
There is a set_setting
command which could be used to set the font size to one that you desire in a key binding, but this only modifies the font size of the current view (while the commands above make the change permanent globally), so this is a non-solution.
A solution that doesn't require a plugin to modify the behaviour would be to remove the binding from the mouse wheel entirely, or alter it so that it requires a different modifier key. That way it won't trigger by accident at all.
In order to do that, you need to create or modify the file Packages\User\Default.sublime-mousemap
. In order to determine where your User
package is stored, you can use Preferences > Browse Packages
from the menu.
Something like the following stored as the contents of that file will remove the binding completely, so that font changes with the mouse wheel are not possible. If the file already exists, just add the second and third lines to the file, making sure that all entries end in a comma.
[ { "button": "scroll_down", "modifiers": ["ctrl"], "command": "noop" }, { "button": "scroll_up", "modifiers": ["ctrl"], "command": "noop" } ]
If you still want this functionality from the mouse, then you need a couple of extra lines to add the commands back. It's important that the two lines that map to the noop
command remain; if you don't override them explicitly the defaults will remain.
Here's an example of requiring Shift and Control to both be held during a mouse scroll to modify the font size.
[ { "button": "scroll_down", "modifiers": ["ctrl"], "command": "noop" }, { "button": "scroll_up", "modifiers": ["ctrl"], "command": "noop" }, { "button": "scroll_down", "modifiers": ["shift", "ctrl"], "command": "decrease_font_size" }, { "button": "scroll_up", "modifiers": ["shift", "ctrl"], "command": "increase_font_size" } ]
Go to Preference->Settings and change the font size as you want....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With