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

时间:2017-01-04 05:15:54

标签: sublimetext3

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

1.curly bracket

.configure
make
sudo make install

2.parenthesis

xxx = {
  |cursor|
}

3.方括号

xxx = (
  |cursor|)

我怎样才能将它们全部设置为大括号

1 个答案:

答案 0 :(得分: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 }
    ]
},

提供了在{}大括号之间按 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 }
    ]
},