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

Off*_*fCS 7 sublimetext3

当我点击一个新的行按钮时,Sublime Text有3种方法来处理括号缩进.

支架

xxx = {
  |cursor|
}
Run Code Online (Sandbox Code Playgroud)

2.parenthesis

xxx = (
  |cursor|)
Run Code Online (Sandbox Code Playgroud)

3.方括号

xxx = [
|cursor|]
Run Code Online (Sandbox Code Playgroud)

我怎么能把它们全部设置成像花括号一样

Kei*_*all 10

在默认键绑定中,有以下内容:

{ "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 }
    ]
},
Run Code Online (Sandbox Code Playgroud)

它提供了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 }
    ]
},
Run Code Online (Sandbox Code Playgroud)

  • 你好 这对我有所帮助,但是我仍然有不同的举止。使用括号时,将使用光标将右括号缩进,对于方括号,则根本不会缩进光标。 (2认同)