编辑器自定义:如何更改布尔关键字的颜色?

问题描述 投票:0回答:2

我正在尝试调整编辑器的外观。

使用 "editor.tokenColorCustomizations""editor.semanticTokenColorCustomizations" 设置,我已成功进行所有所需的调整,除了 true/false 关键字。

尽我所能进行搜索,我找不到控制这些关键字外观的设置。请提供建议。

visual-studio-code editor customization
2个回答
5
投票

您可以使用此代码来更改 true 和 false 的颜色:

"editor.tokenColorCustomizations": {
    "[<THEME_NAME>]": {
        "textMateRules": [
            {
                "scope": "constant.language",
                "settings": {
                    "foreground": "<COLOR_CODE>"
                }
            }
        ]
    }
},

0
投票

我使用 TODO Highlight 视觉工作室扩展来标记我的 truefalse 值。请注意,默认情况下扩展会过滤文本区分大小写。

我将此部分添加到我的

.vscode/settings.json

...
    "todohighlight.include": [
        "**/*.json",
        "**/*.cs"
    ],
    "todohighlight.keywords": [
        {
            "text": "true",
            "color": "#00ff00",
            "backgroundColor": "editor.background",
            // "overviewRulerColor": "green",
            // "border": "blue 1px solid"
        },
        {
            "text": "false",
            "color": "#FF0000",
            "backgroundColor": "editor.background",
            // "overviewRulerColor": "red"
        }
    ],
...

过滤器对

json
cs
文件有效。 true 将显示为绿色, false 将显示为红色。使用选项
overviewRulerColor
,您可以在标尺/滚动条中标记结果。

查看这些链接了解更多详情:

我受到了 reddit.com 上的 帖子的启发。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.