【发布时间】:2021-04-28 13:47:08
【问题描述】:
使用崇高的文字。类似于添加新括号 { 并按 Enter 键时,它会创建一个新的缩进块,如下所示(... 是空格):
{
....
}
我希望在使用反引号时发生同样的事情(因为我使用的是 stlyed-components)。
所以当我输入`+enter,我会得到:
`
....
`
我该怎么做?
【问题讨论】:
使用崇高的文字。类似于添加新括号 { 并按 Enter 键时,它会创建一个新的缩进块,如下所示(... 是空格):
{
....
}
我希望在使用反引号时发生同样的事情(因为我使用的是 stlyed-components)。
所以当我输入`+enter,我会得到:
`
....
`
我该怎么做?
【问题讨论】:
您需要一个新的 Enter 键绑定,具有特定条件。打开 Preferences → Key Bindings 并在右侧添加以下内容:
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "`$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true }
]
},
只有在您启用了"auto_indent" 设置、选择为空且光标前后的字符为反引号时才会运行。
【讨论】: