首页 > 解决方案 > 在 VSCode 主题中自定义块引用颜色

问题描述

我在 VScode 中使用Nord 主题。降价文件中的块引号看起来像这样,非常难以辨认。如何更改文字背景?

在此处输入图像描述

我在用户设置中尝试了以下操作,但它不起作用:

"workbench.colorCustomizations": {
    "textBlockQuote.background": "#ff0000", // changes the markdown preview
    "editor.textBlockQuote.background": "#0000ff", // Property not allowed
    "[Nord]": {
        "textBlockQuote.background": "#ff0000", // changes the markdown preview
    },
},
"editor.tokenColorCustomizations": {
    "textBlockQuote.background": "#ff0000", // Property not allowed
    "editor.textBlockQuote.background": "#ff0000", // Property not allowed
    "[Nord]": {
        "textBlockQuote.background": "#ff0000", // Property not allowed 
        "editor.textBlockQuote.background": "#ff0000", // Property not allowed
    }
},

标签: visual-studio-code

解决方案


编辑器着色来自 textmate 语法。要覆盖它,您需要textMateRules使用editor.tokenColorCustomizations

"editor.tokenColorCustomizations": {
    "[Nord]": {
        "textMateRules": [
            {
                "scope": "markup.quote.markdown",
                "settings": {
                    "foreground": "#f0f"
                }
            }
        ]
    }
}

这里使用的范围 ( markup.quote.markdown) 是 markdown 块引号的 textmate 范围。您可以使用Developer: Inspect TM ScopesVS Code 中的命令来确定目标范围

请注意,VS Code 不支持设置文本的背景颜色。这是跟踪here


推荐阅读