Как установить кронштейн поведения отступ в СТ3
Sublime Text имеет 3 способа обработки отступа скобок, когда я нажимаю кнопку новой строки.
1.фигурная скобка
xxx = {
|cursor|
}
2.скобки
xxx = (
|cursor|)
3.квадратная скобка
xxx = [
|cursor|]
Как я могу настроить их все так, чтобы они вели себя как фигурные скобки
1 ответ:
В связках клавиш по умолчанию есть следующее:
{ "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 } ] },