Home > front end >  VSCode color customisation, Include regexp check in textMateRules
VSCode color customisation, Include regexp check in textMateRules

Time:10-05

I'm trying to customize my VSCode theme using textMateRules. What I want to do is to change the color class names, but not all of them, only specific ones.

For example, in the project I'm working in, we have classes: A, B, C, D ...

A and B are "special" classes and I would like to highlight them differently (let say in red). This is what I added for now in my setting.json file:

{
    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "entity.name.type.class",
                
                "settings": {
                    "foreground": "#FF0000",
                }
            },
        ]
    },
}

But it is highlighting all the classes names (including C, D and all the others).

Is there a way to add more rules to the scope, like a regexp match?

CodePudding user response:

As recommended by @rioV8 I used the Highlight extension:

And I added this in my setting.json:

{
  "highlight.regexes": {
    "(A|B)": {
      "decorations": [
        {
          "color": "red"
        },
      ]
    }
  },
}
  • Related