Home > database >  VS Code: Is it possible to specify a token color customization that requires multiple scopes at once
VS Code: Is it possible to specify a token color customization that requires multiple scopes at once

Time:12-07

VS Code allows users to customize syntax highlighting colors for specific syntax in settings.json. The most flexible way to do this is using the "textMateRules" property, which is formatted something like this:

"editor.tokenColorCustomizations": {
  "textMateRules": [{
    "scope": ["keyword.other", "keyword.control"],
    "settings": {
      "foreground": "#FF0000",
      "fontStyle": "bold"
    }
  }]
}

The problem with the above snippet is that it applies the selected styles to either keyword.other OR keyword.control scopes. Is it possible to devise a textMateRules configuration that requires the keyword.other AND the keyword.control scopes?

CodePudding user response:

See also https://stackoverflow.com/a/64836542/836330

Use this form:

"editor.tokenColorCustomizations": {
  "textMateRules": [{
    "scope": "keyword.other keyword.control",
    "settings": {
      "foreground": "#FF0000",
      "fontStyle": "bold"
    }
  }]
}

"scope": "keyword.other keyword.control", // note separated by a space, one string

This form will require BOTH scopes to be present in order to be applied.

  • Related