【问题标题】:Change comment and block comment colors separately in VS code在 VS 代码中分别更改注释和阻止注释颜色
【发布时间】:2021-04-19 05:22:47
【问题描述】:

我正在尝试找出如何为单行注释指定一种颜色,为块注释(多行)指定另一种颜色。

以下适用于将所有 cmets 设置为某种颜色:

"editor.tokenColorCustomizations": {
        "comments" :"#ff0022",
    }

有没有办法单独指定它们?例如"blockComment" : "#00FF00", "commentLine" : "#FF00222"

【问题讨论】:

  • 如果您的语言服务器为这些 cmets 设置了不同的 TextMate 范围,您可以设置不同的颜色
  • @rioV8 谢谢。试过"textMateRules",现在可以自定义两种cmets的颜色了。
  • 发布编辑作为问题的答案,以便将其标记为已解决
  • @rioV8 完成。除此之外,我确实想知道为什么 'punctuation.definition.comment' 似乎没有正确显示。
  • 查看主题文件:使用数组作为作用域是OR 作用域,我认为如果你想要AND 作用域,你必须使用像"scope1 scope2" 这样的字符串

标签: visual-studio-code vscode-settings


【解决方案1】:

使用"textMateRules" 设置"comment.block" 的范围设置,"comment.line" 可以单独设置颜色。

"editor.tokenColorCustomizations": {
    "textMateRules": [{
        "scope": "comment.block",
        "settings": {
            "foreground": "#0000"
        }
    },
    {
        "scope": "comment.line",
        "settings": {
            "foreground": "#0000FF"
        }
    }],
}

更改标点符号"punctuation.definition.comment.js"(js):

"editor.tokenColorCustomizations": {
    "textMateRules": [{
        "scope": "comment.line, punctuation.definition.comment.js",
        "settings": {
            "foreground": "#00FF00"
        }
    }]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-24
    • 2011-10-22
    • 1970-01-01
    • 2019-02-09
    • 2011-12-31
    • 1970-01-01
    • 2023-03-21
    • 2023-02-07
    相关资源
    最近更新 更多