简体   繁体   English

有没有办法改变VScode中评论的背景颜色?

[英]Is there any way to change background color of comments in VScode?

I would like to change the color of the comments so that it can be highlighted.我想更改评论的颜色,以便突出显示。 I prefer to change background-color most of the time.大多数时候我更喜欢更改背景颜色。 I found the color setting in setting.json .我在setting.json中找到了颜色设置。 it looks like this.它看起来像这样。

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "comment",
            "settings": {
                "fontStyle": "bold",
                "foreground": "#FFD83B"
            }
        }
    ]
}

It does change but it seems like there is no "background" option in "settings".它确实发生了变化,但似乎“设置”中没有“背景”选项。 it says "Token background colors are currently not supported."它说“目前不支持令牌背景 colors。” so I only can change the text color, not the background.所以我只能改变文字颜色,不能改变背景。 is there any way I can set background color of comments in VSCode?有什么方法可以在 VSCode 中设置评论的背景颜色?

There isn't any way to do that built-in.没有任何内置方法可以做到这一点。 You could look through the extensions - search for comment - to see if any of them do that.您可以查看扩展名 - 搜索comment - 看看他们中的任何一个是否这样做。

Alternatively, one way to do it would be to use an extension like highlight .或者,一种方法是使用诸如highlight之类的扩展。 You can style anything you can capture with a regex.您可以使用正则表达式设置您可以捕获的任何内容。 In settings.json:在 settings.json 中:

"highlight.regexes": {

 "(//\\s*)(\\sTODO\\s)(\\s*?:?)(.*)": [
   {},
   {
    "overviewRulerColor": "#ffcc00", // does this work?
    // "backgroundColor": "#aaa",
    "color": "#fff",
    "fontWeight": "bold",
    "letterSpacing": "2.5px",
    "outline": "1px solid #aaa",
    // "border": "1px solid #fff",
    // "before": {
    //   "backgroundColor": "#fff",
    //   "contentText": " *** ",
    //   "fontWeight": "bold",
    //   "margin": "10px"
    //   // "width": "20px"
    // }
   },
   {},
   {
    "color": "#999",
    "fontStyle": "italic",
    "letterSpacing": "1px"
   }
 ],

 "(//\\s*)(-+\\s+//)": [
   {
    "color": "#000",
    "backgroundColor": "#aaa",
    "outline": "2px solid #aaa",
    "fontWeight": "bold",
   },
   {
    "overviewRulerColor": "#ffcc00",
    "backgroundColor": "#aaa",
    "color": "#000",
    "fontWeight": "bold",
    // "letterSpacing": "2.5px",
    "outline": "2px solid #aaa",
    // "border": "1px solid #fff",
    // "before": {
    //   "backgroundColor": "#fff",
    //   "contentText": " *** ",
    //   "fontWeight": "bold",
    //   "margin": "10px"
    //   // "width": "20px"
    // }
   },
 ]
},

yields:产量:

高亮演示

For styling options, see https://code.visualstudio.com/api/references/vscode-api#DecorationRenderOptions有关样式选项,请参阅https://code.visualstudio.com/api/references/vscode-api#DecorationRenderOptions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM