简体   繁体   中英

VS Code Set JavaScript Property color

I'm trying to figure out how to change object property colors in JS files in VS Code. For example:

var vehicle = {
    type: "Fiat",
    model: "500",
    color: "white"
};

How would I set the color for "type, model and color" properties?

I was thinking this would work in settings.json, but it does not:

"editor.tokenColorCustomizations": {
    "functions": {
        "fontStyle": ""
    },
    "[TommyTachas]": {
        "comments": "#db33a3",
        "textMateRules": [
            {
                "scope": "support.type.property-name.js",
                "settings": {
                    "foreground": "#ff0000"
                }
            }
        ]
    }
}

The scope to use is variable.other.property.js

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      { "scope":"variable.other.property.js",
        "settings": {"foreground": "#00ff00"}
      }
    ]
  }

In your case if you want to change the var color it'll be "storage.type.js"

The following link has the information you are look for.

https://github.com/microsoft/vscode/issues/76308?msclkid=bfff79bec58d11eca167869d42275429

Try it

  "editor.semanticTokenColorCustomizations": {
     "[your current theme]": {
        "rules": {
        "property": "#AE81FF"
     }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM