Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make VSCode Variables have Colour

I would like to make variables displayed with colours.

This is how it looks:

Python

This is how I want it to be:

Variable Colored

Looking through here, I cannot find any settings that allow me to change this.

like image 902
IllustriousMagenta Avatar asked Dec 09 '17 02:12

IllustriousMagenta


People also ask

How do I change the color of a variable in VS Code?

Press 'Ctrl+shift+P' from the keyboard to open VS Code command palette. Search: 'Inspect Editor Tokens and Scopes' Take the cursor on the text or tag, if you want to change the colors.

How do I enable color in VS Code?

The active color theme is stored in your user settings (keyboard shortcut Ctrl+,). Tip: By default, the theme is stored in your user settings and applies globally to all workspaces. You can also configure a workspace specific theme. To do so, set a theme in the Workspace settings.

How do I change VS Code syntax highlighting?

To customize it, you have to edit the settings file used by your VS Code. To do that, open the VS Code Command Palette, search for “Settings. json” and edit it.


2 Answers

Try this setting in your settings.json:

 "editor.tokenColorCustomizations": {
    "variables": "#f00"
 },

There are a few such simple token color customizations available: variables, comments, keywords, functions, numbers, strings and types. Those only allow setting the color though.

If you use "textMateRules" you can set more properties. For example:

"editor.tokenColorCustomizations": {
  "textMateRules": [
    {
      "scope": "comment",
      "settings": {
        "fontStyle": "italic",
        "foreground": "#C69650"
      }
    }
  ]
},
like image 56
Mark Avatar answered Oct 12 '22 09:10

Mark


This is working for me. It makes it look like the default Javascript formatting as far as I can see.

In settings.json

"editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": "meta.function-call.generic.python",
        "settings": {
          "foreground": "#DCDCAA"
        }
      },
      {
        "scope": "source.python",
        "settings": {
          "foreground": "#9CDCFE"
        }
      },
      {
        "scope": "punctuation.definition.string.begin",
        "settings": {
          "foreground": "#ce9178"
        }
      },
      {
        "scope": "punctuation.definition.string.end",
        "settings": {
          "foreground": "#ce9178"
        }
      },
      {
        "scope": "punctuation",
        "settings": {
          "foreground": "#dfdfdf"
        }
      }
    ]
}
like image 33
Austin Gomez Avatar answered Oct 12 '22 07:10

Austin Gomez