将 - -(双破折号)转换为 ->在 SublimeText 3 中自动 [英] Convert - -(double dash) to -> automatically in SublimeText 3
问题描述
在我的工作中,我多次使用 -> 并且在匈牙利键盘上没有专用的 > 按钮,所以我必须使用 3 个键来输入这个,有时我也会打错.有没有办法自动转换--(双破折号)->?Snippet 不太好,因为它需要一个 TAB 才能转换.谢谢
During my work I use -> many times and on a hungarian keyboard there is no dedicated > button, so I have to use 3 keys to enter this and sometimes I also misstype. Is there a way to convert -- (double dash) automatically a ->? Snippet is not so good because it requires a TAB to convert. Thanks
推荐答案
可以通过一个简单的键绑定来做到这一点,例如:
It's possible to do this with a simple key binding such as the following:
{
"keys": ["-", "-"],
"command": "insert", "args": {
"characters": "->"
},
},
现在,当你输入 --
时,只要你点击第二个 -
它就会触发并像你一样用 ->
替换文本想要.
Now when you type --
as soon as you hit the second -
it triggers and replaces the text with ->
like you want.
但是请注意,这将适用于每个文件中文本 --
的每次使用.这可以在一定程度上通过在键绑定中使用 context
来限制,使其仅适用于某些文件,例如确保绑定仅在纯文本文件中有效的文件:>
Note however that this would apply to every usage of the text --
in every file. This could be constrained to some degree by using a context
in the key binding that makes it apply only in certain files, such as this one that ensures that the binding is only valid in plain text files:
{
"keys": ["-", "-"],
"command": "insert", "args": {
"characters": "->"
},
"context": [
{
"key": "selector",
"operator": "equal",
"operand": "text.plain",
"match_all": true
},
],
},
这可以应用于您想要的任何范围;使用<代码>工具>开发人员在编辑文件时从菜单中显示范围名称... 以确定您需要的范围(通常您可能只需要第一个范围项).
This can be applied to any scope you want; use Tools > Developer > Show Scope Name...
from the menu while editing a file to determine the scope that you need (generally you probably want only the first scope item).
无论哪种方式,这都使得直接键入 --
而不在两个 -
字符之间故意长时间停顿或执行退格键是不可能的.这可能是也可能不是问题.
Either way, this makes it impossible to type --
directly without including a deliberate long pause between the two -
characters or doing a backspace. That may or may not be an issue.
这篇关于将 - -(双破折号)转换为 ->在 SublimeText 3 中自动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!