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 }
]
},
which provides the functionality for pressing Enter 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 }
]
},