问题
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"
.
回答1:
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" }
]
回答2:
Go to Preference->Settings and change the font size as you want....
回答3:
However, there isn't a keyboard shortcut for resetting the zoom/font size. Normally this would be super + 0
(aka cmd + 0
) in most apps, but Sublime Text doesn't give you this by default.
To get this feature you need to add the following to your keyboard bindings (found under Preferences -> Key Bindings
)
{ "keys": ["super+0"], "command": "reset_font_size" }
Courtesy: coderwall.com
回答4:
Go to Preferences>keybinding
{ "keys": ["ctrl+shift+0",], "command": "reset_font_size" },
add this line at the last line before "]" in the right panel and save it.
Now every time you want to reset use this keyboard shortcut.
回答5:
Press ctrl + to increase font and ctrl shift + to decrease font size. I used and it works.
来源:https://stackoverflow.com/questions/41326348/resetting-font-size-shortcut-for-sublime-text-3