2

我试图弄清楚如何更改 CSS 的 Sublime Texts 自动括号规则。

我默认得到这个:

.class {
    #CURSOR
}

我想要这个:

.class {
    #CURSOR}

关于如何做到这一点的任何想法?

4

1 回答 1

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" }
    ]
}

修改文件的enter关键行为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" }
    ]
}
于 2013-02-06T17:28:11.087 回答