VSCode设置:着色自定义标签,其以“x-”前缀开头

huangapple go评论60阅读模式
英文:

VSCode settings : colorize custom tags that start with the "x-" prefix

问题

我想编写一个在其中以前缀 x- 开头的标签(在 .vue 文件中)将被着绿色的Visual Studio Code设置。

<x-component></x-component><x-lorem></x-lorem>这样的标签。

是否可能?如何实现?

我尝试了这个:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "entity.name.tag.x-*",
            "settings": {
                "foreground": "#00ff00"
            }
        }
    ]
},

但它不起作用。

英文:

I want to write a vscode setting in which tags ( inside .vue file ) that start with the prefix x- will be colored green.

tags like <x-component></x-component> and <x-lorem></x-lorem>

is it possible? and how

i tried this


"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "entity.name.tag.x-*",
            "settings": {
                "foreground": "#00ff00"
            }
        }
    ]
},

and it not works

答案1

得分: 0

抱歉,似乎在不安装插件的情况下是不可能的。
我使用了@rioV8提到的Highlight 插件
它有效果

这是我的配置:

  "highlight.regexes": {
    "(<[^>]*x-[^>]*>)": { // 从这个字符串创建正则表达式,不要忘记双重转义
      "decorations": [ // 应用于捕获组的装饰选项
        { "color": "#7ac379" }, // 应用于第一个捕获组的装饰选项,在这种情况下是"//<-x:"
      ]
    }
  }

英文:

Unfortunately, it seems that this is not possible without installing the plugin
I used the Highlight plugin mentioned by @rioV8
it works

this is my config :

  "highlight.regexes": {
    "(<[^>]*x-[^>]*>)": { // A regex will be created from this string, don't forget to double escape it
      "decorations": [ // Decoration options to apply to the capturing groups
        { "color": "#7ac379" }, // Decoration options to apply to the first capturing group, in this case "//<-x:"
      ]
    }
  }

huangapple
  • 本文由 发表于 2023年2月14日 21:39:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75448663.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定