【发布时间】:2021-08-25 18:58:37
【问题描述】:
我有这个初始场景,| 表示我的光标:
for(int i=0;i<n;i++){|}
回车后的结果:
for(int i=0;i<n;i++){
|}
想要的结果:
for(int i=0;i<n;i++){
|
}
我尝试了this,但没有解决我的问题。
我使用了以下键绑定,但它不起作用:
[
{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "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": true,
"smart_indent": true,
"indent_to_bracket": true,
"trim_automatic_white_space": true,
我该如何解决?
编辑:- 我卸载了 Sublime Text4 并安装了 Sublime Text3。它工作正常。我会坚持下去的。
【问题讨论】:
-
在链接的解决方案中,您是否将 () 更改为 {} 以匹配您的用例?
-
@KabirKanhaArora 是的,我做到了。但是没有用:(
-
已经有一个默认的键绑定可以做到这一点,但它需要打开
auto_indent(就像您喜欢的解决方案中的键绑定一样)。你启用了吗? (如果没有,打开它并删除您添加的绑定)。 -
@lazy_propagator 您能否请edit 提出您的问题并粘贴您尝试但没有成功的键绑定代码?谢谢。
-
@MattDMo 我已经添加了。
标签: sublimetext3 newline indentation key-bindings sublime-text-plugin