我正在试图弄清楚如何为css更改Sublime Texts自动括号规则。
默认情况下我这样做:
.class {
#CURSOR
}
我想有这个:
.class {
#CURSOR}
关于如何实现这一目标的任何想法?
答案 0 :(得分:3)
您可以将此快捷方式添加到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
文件修改输入键行为。
或者您可以使用代码段。 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" }
]
}