本文介绍了如何在ST3中设置括号缩进行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我按下换行键时,Sublime Text有3种方法来处理方括号缩进.
Sublime Text has 3 ways to handle brackets indentation when I hit a new line button.
1.curly括号
xxx = {
|cursor|
}
2.括号
xxx = (
|cursor|)
3.方括号
xxx = [
|cursor|]
如何设置它们的行为都像花括号
How could I set all of them to behave like curly bracket
推荐答案
在默认键绑定中,有以下内容:
In the Default keybindings, there is this:
{ "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 }
]
},
提供在{
和}
大括号之间按的功能.宏会添加2个换行符,将光标移动到第一个换行符之后,然后重新缩进该行.
which provides the functionality for pressing between the {
and }
braces. The macro adds 2 newlines, moves the cursor to after the first one and reindents the line.
因此,您可以通过将(
和)
以及[
和]
添加到用户键绑定中来实现相同的功能:
You can therefore achieve the same functionality between (
and )
and [
and ]
by adding this to your user keybindings:
{ "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 }
]
},
这篇关于如何在ST3中设置括号缩进行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!