【发布时间】:2019-11-25 03:47:01
【问题描述】:
当我输入( 并点击Space 时,我希望Sublime Text 自动添加一个空格并移动插入符号,因此最终结果是( ^ ),其中^ 是光标。
如何调整键绑定以实现这一点?
我已经能够使用
调整键绑定{ "keys": ["("], "command": "insert_snippet", "args": {"contents": "( $0 )"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true }
]
}
但是在输入( 时,这将始终将其格式化为( ^ )。我宁愿在点击space 后将其格式化。
我可以在默认绑定中看到在输入 { 后点击 enter 的情况,这将运行一个宏,所以我想我可以将它用作模板,但我无法在我的文件系统上找到该宏看看它是如何工作的。
{ "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 }
]
},
【问题讨论】:
-
请参阅“How to Ask”以及链接页面和“mcve”。你研究过这个吗?在哪里?如果它没有帮助告诉我们原因。你尝试了什么?如果你不尝试,为什么不呢?如果你做了,你做了什么?我们希望看到您尝试解决这个问题。