Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 269
Sam Weaver Avatar asked Sep 19 '25 23:09

Sam Weaver


1 Answers

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.

like image 191
Mark Avatar answered Sep 22 '25 12:09

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!