Mike Will
Mike Will

Reputation: 309

VScode JS syntax color for Object Key

I am trying to set color for object key: {key:'string'}

Closer I got is adding in settings.json this: "workbench.colorCustomizations": {},

But what settings should I add further?

Upvotes: 0

Views: 747

Answers (1)

Juno Burger
Juno Burger

Reputation: 61

If the OP or anyone is still looking for an answer to this question.

In your settings.json file

"workbench.colorCustomizations": {
        "textMateRules": [
    {
                "scope": "meta.object-literal.key",
                "settings": {
                    "foreground": "#FF0000", // any color you like
                    // any other styling you want to apply
                }
            }
      ]
}

to get the correct scope you can open up the command panel on your javascript/typescript/any file in vscode with cmd+shift+p or ctrl+shift+p on a PC.

Search: >Developer: inspect Editor Tokens and Scopes
Then you can click on specific syntax to get the correct scope.
You'll get something looking like this: enter image description here

If you want the styling to only apply to a specific theme the following will help you https://egghead.io/lessons/vs-code-adding-custom-syntax-highlighting-to-a-theme-in-vscode

Upvotes: 3

Related Questions