Visual studio code 如何在VisualStudio代码中自定义HTML模板道具的颜色?

Visual studio code 如何在VisualStudio代码中自定义HTML模板道具的颜色?,visual-studio-code,vscode-settings,Visual Studio Code,Vscode Settings,使用检查以下代码中的胡须内容 名称:{{name} 我得到了text.html.basic,这意味着在mustache标签中没有单独的范围来更改name的颜色。在Visual Studio代码中是否有其他方法可以更改模板道具的颜色?如果没有更好的方法使用范围,可以尝试 这种设置似乎很有效: "highlight.regexes": { "({{[/!^>#]*\\s*)([^}]+)(\\s*}})": [ {}, // first match group

使用检查以下代码中的胡须内容

名称:{{name}


我得到了
text.html.basic
,这意味着在mustache标签中没有单独的范围来更改
name
的颜色。在Visual Studio代码中是否有其他方法可以更改模板道具的颜色?

如果没有更好的方法使用范围,可以尝试

这种设置似乎很有效:

"highlight.regexes": {

    "({{[/!^>#]*\\s*)([^}]+)(\\s*}})": [
         {},  // first match group "{{" gets no color, must be here
         {
            // "overviewRulerColor": "#ffcc00",
            "color": "#f00",
            // "fontWeight": "bold"
         },
         {} // third match group "}}" gets no color, does not need to be here
     ],
}

如果找不到更好的使用范围的方法,可以尝试使用

这种设置似乎很有效:

"highlight.regexes": {

    "({{[/!^>#]*\\s*)([^}]+)(\\s*}})": [
         {},  // first match group "{{" gets no color, must be here
         {
            // "overviewRulerColor": "#ffcc00",
            "color": "#f00",
            // "fontWeight": "bold"
         },
         {} // third match group "}}" gets no color, does not need to be here
     ],
}

编辑:改变正则表达式,这样模板模板的理想捕获就更好了,并且更新了图像示例。我想你在中间缺少了<>代码> <代码>。你写的方式可能会去掉第三种模式。这里有一个角道具绑定:
“(\\s+\[[\\w-]+\]=\”[/!^>\\]*)([^\“]+)”
你的评论是对的,我在正则表达式上的一个输入错误,最后一个匹配组不需要包含,如果你什么也不做。编辑:改变正则表达式,这样模板模板的理想捕获就更好了,并且更新了图像示例。我想你在中间缺少了<>代码> <代码>。你写的方式可能会去掉第三种模式。这里有一个角度道具绑定:
“(\\s+\[\\w-]+\]=\”[/!^>\\\]*)([^\“]+)”
您的评论是对的,我在正则表达式中输入了一个错别字,如果您不使用它,则不需要包含最后一个匹配组。