Been quite some time! Any update on this? Can it be done now?
Edit: found a fix on these forums:
[quote=“Ildefonse”]Thanks, that was useful. I added this code to the user keybindings:
{ "keys": "enter"], "command": "run_macro_file", "args": {"file": "Packages/User/Macros/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": "array\\($", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true }
]
}
But this still had one flaw: the closing parenthesis “)” was placed one tab too far indented to the right. I am not sure what does this, as it only happens with parentheses, and not with for example “” or square brackets ].
Anyway, I fixed this odd behavior by modifying the “Add Line in Braces” macro (after copying to user folder), changing it to:
{"command": "insert", "args": {"characters": "\n\n"} },
{"command": "left_delete", "args": null},
{"command": "move", "args": {"by": "lines", "forward": false} },
{"command": "move_to", "args": {"to": "hardeol", "extend": false} },
{"command": "reindent", "args": {"single_line": true} }
]
I added in the second line, and now it works like a charm.
Thanks again for helping me find this, I hope someone else finds the solution useful as well, or maybe Sublime will implement it in their default packages and keybindings.[/quote]