如何在 ST3 中设置括号缩进行为

How to set bracket indentation behavior in ST3

当我点击换行按钮时,Sublime Text 有 3 种方法来处理括号缩进。

1.curly括号

xxx = {
  |cursor|
}

2.parenthesis

xxx = (
  |cursor|)

3.square括号

xxx = [
|cursor|]

我怎样才能将它们都设置为像花括号一样

在默认键绑定中,有这样的:

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

它提供了在 {} 大括号之间按 Enter 的功能。宏添加 2 个换行符,将光标移动到第一个换行符之后并重新缩进该行。

因此,您可以在 () 以及 [] 之间实现相同的功能,方法是将此添加到您的用户键绑定:

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