如何更改VS代码中区域/结束区域的颜色



有人知道如何更改#region/#endregion的颜色吗?这在VS社区中是灰色的,但在VS代码中不是。

提前谢谢。

因为术语#region/#endregion是注释的一部分,所以用命令Developer: Inspect TM Scopes查看它们的作用域只能得到comment作用域,因此如果您通过以下标记ColorCustomization更改注释作用域:

"editor.tokenColorCustomizations": {
"comments": "#ffa600b0"
}

将更改所有注释-可能不是您想要的。此外,您只能在那里更改fontColor和fontStyle(如斜体(。

更好的方法是使用扩展Highlight,通过regex查找您想要突出显示的内容。

使用//#region-您的语言在开始时可能会有不同的注释指示符。如果是,请修改下面的第一个捕获组(//\s*)

"highlight.regexes": {
"(//\s*)(#region|#endregion)": [
// the first capture group, the '//' uncolored here, but must have the entry below
//  you could color those separately if you wish
{},
// capture group: #region or #endregion
{
// "overviewRulerColor": "#ffcc00",
"backgroundColor": "#f00",
"color": "#fff",
// "fontWeight": "bold",
"borderRadius": "3px",
},
]
}

尝试使用此扩展。现在非常适合我。

更好的评论-Visual Studio Marketplace

这是我的设置。您只能使用";区域";以及";"端部区域";为你自己。

"better-comments.tags": [
{
"tag": "region -",
"color": "rgba(0,96,100,5)",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "region",
"color": "#00F5FF",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "endregion",
"color": "rgba(0,96,100,10)",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "!",
"color": "#FF2D00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "?",
"color": "#3498DB",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "//",
"color": "#474747",
"strikethrough": true,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "todo",
"color": "#FF8C00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "*",
"color": "#98C379",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
],

以下是的外观

相关内容