重置 Sublime Text 3 的字体大小快捷方式 [英] Resetting font size shortcut for Sublime Text 3

查看:56
本文介绍了重置 Sublime Text 3 的字体大小快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢使用 Sublime Text,但它的功能之一有时让我烦恼,那就是 意外放大".每当发生这种情况时,它就会打破势头,我必须将其改回原来的位置,这有点烦人.我搜索了一个可以将大小重置为正常的快捷方式,但每个快捷方式都涉及创建一个 python 文件,并且由于某种原因它对我不起作用.

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.

如果我可以在 Preference.sublime-settings 文件中更改某些内容并将字体重置回我想要的位置,那么我的生活会变得更轻松,例如 <代码>Control+0".

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".

推荐答案

对于背景,Sublime Text 3 有名为 increase_font_sizedecrease_font_size 的命令.这些命令将字体大小向上或向下修改某个值(取决于当前设置的值),然后直接修改 Preferences.sublime-settings 文件中的设置,这使得更改在任何地方都是永久的.

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.

这些命令默认绑定到 Ctrl+WheelUp/Down 以及 Ctrl++Ctrl+-.

These commands are bound by default to Ctrl+WheelUp/Down as well as Ctrl++ and Ctrl+-.

存在一个命令reset_font_size(默认情况下不绑定到一个键),但是这个命令通过完全擦除字体大小设置来工作;因此,如果您没有使用默认字体大小,这不太可能有用.此外,这也不会重置任何,例如特定于语法的字体大小.

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.

有一个 set_setting 命令可用于将字体大小设置为您在键绑定中所需的字体大小,但这只会修改当前视图的字体大小(而上面的命令使更改永久全局),所以这是一个非解决方案.

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.

为此,您需要创建或修改文件 Packages\User\Default.sublime-mousemap.为了确定您的 User 包的存储位置,您可以使用 Preferences >从菜单浏览包.

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" }
]

如果您仍然希望通过鼠标获得此功能,那么您需要多加几行来添加这些命令.保留映射到 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.

这是一个要求在鼠标滚动期间按住 ShiftControl 以修改字体大小的示例.

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" }
]

这篇关于重置 Sublime Text 3 的字体大小快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆