您可以将此快捷方式添加到您的Key Bindings - User:
{ "keys": ["enter"], "command": "insert", "args": {"characters": "\n\t"}, "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 },
{ "key": "selector", "operator": "equal", "operand": "source.css" }
]
}
使用css 文件修改enter 键行为。
或者您可以使用代码段。 Tools/New Snippet...:
<snippet>
<content><![CDATA[
{
${1}}
]]>
</content>
</snippet>
另存为Packages/User/CSSBrackets.sublime-snippet。
然后,在Key Bindings - User 中添加一个快捷方式,以便在css 文件中按 { 时触发它:
{ "keys": ["{"], "command": "insert_snippet", "args": {"name": "Packages/User/CSSBrackets.sublime-snippet"},
"context":
[
{ "key": "selector", "operator": "equal", "operand": "source.css" }
]
}