css - Sublime Text 3 - CSS 属性的配色方案

标签 css xml sublimetext3 markup color-scheme

如何更改 Sublime Text 3 中 CSS 属性的配色方案?

我已经修改Monokai.tmTheme并更改了默认 Library variable 的颜色和Variable .

<dict>
    <key>name</key>
    <string>Library variable</string>
    <key>scope</key>
    <string>support.other.variable</string>
    <key>settings</key>
    <dict>
        <key>fontStyle</key>
        <string>italic</string>
        <key>foreground</key>
        <string>#FFB6C1</string>
    </dict>
</dict>
<dict>
    <key>name</key>
    <string>Variable</string>
    <key>scope</key>
    <string>variable</string>
    <key>settings</key>
    <dict>
        <key>fontStyle</key>
        <string>italic</string>
        <key>foreground</key>
        <string>#FFB6C1</string>
    </dict>
</dict>

通过更改最后一个 <string>里面<dict>你可以看到here变量的默认白色更改为粉红色。

我想更改 CSS 属性的默认蓝色,但找不到其相关的标记字符串名称。

最佳答案

正如您所见,这些 .tmTheme文件采用 PList XML 格式。对于配色方案,<string>之后<key>name</key>实际上只是一条评论,在大多数情况下,name key 可能完全丢失,因此最好直接查看 <string>之后<key>scope</key> .

该字符串是 scope selector, and I have explained how they work in a separate answer 。该答案的重要要点是:

In Sublime Text, you can find the scope of the character to the right of the cursor by going to the Tools menu -> Developer -> Show Scope Name.

这将向您显示完整的作用域堆栈,但通常我们只对 color scheme 的最后一个作用域感兴趣。目的。例如,不建议对 meta 进行着色。直接范围,但它可以与非元范围结合使用以获得更精确的着色。查看官方Scope Naming documentation了解更多详情。

(语法定义为文档中的文本分配范围,配色方案使用上述范围选择器为这些范围分配颜色。)

因此,对于 CSS 属性,完整范围可能类似于 source.css meta.property-list.css meta.property-name.css support.type.property-name.css 。如果您只想更新 CSS 属性的颜色,而不更新具有相同 support.type 的其他语法中的其他元素范围,那么你可以使用support.type.property-namesupport.type.property-name.css作为范围选择器。否则,您应该发现配色方案已经匹配 supportsupport.type某处并可以更改与之相关的颜色。

就像在 CSS 中一样,scope selectors also have specificity rules ,但这对于简单的单作用域选择器来说很大程度上无关。这意味着,最好检查配色方案是否已经与您要更改颜色的范围匹配 - 如果匹配,请更新它,否则您通常可以添加新的 <dict>相应地在其他规则之后接近文件末尾。

这些的最低内容dict s 是范围,a settings子词典,通常带有 foreground放。本答案前面链接的官方配色方案文档将详细介绍。

<dict>
    <key>scope</key>
    <string>support.type.property-name.css</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#FFB6C1</string>
    </dict>
</dict>

关于css - Sublime Text 3 - CSS 属性的配色方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45868911/

相关文章:

css - 当我向表格单元格动态添加元素时,如何计算 "width: 100%"?

css - prefers-reduced-transparency 媒体查询参数的动机是什么

xml - 捕获不是其他节点的后代的节点,当前上下文除外

eclipse - Sublime Text 3 有集成终端?

python - Sublime Text 3、Python 3 和 UTF-8 彼此不喜欢

html - html中的悬停样式属性

css - 如何在 MUI AppBar 中将 Button 对齐到最右边?

xml - Razor 而不是 XSLT 来转换 MVC3/MVC4 应用程序中的 XML 文档?

xml - 连接几个节点 xsl

javascript - 触发 SublimeText 自定义片段时如何省略(或删除)自动匹配括号?