VS Code, changing color theme for variables

10,914

Solution 1

UPDATE: this is now possible with the C++ extension. Upvote @TheBat's answer since he originally posted the update. The scope is variable.other.local and his answer shows what to add to your settings file.

NOTE: the answer below is still accurate if you do not have the extension

I'm the maintainer of the VS Code C++ Syntax, and sadly there is not yet a way to change the color of all C++ variables, the Python syntax is the same way. You can change the color of source.cpp which will change the default color, and you can change the color of some existing variables with variable and variable.parameter, but this will still not affect many of the untagged variables.

We're working on changing this, but it is going to take quite awhile. For general scope names, look at https://macromates.com/manual/en/language_grammars#naming-conventions

Solution 2

This has changed since the original answer was posted and it is now outdated. As @alex-myers mentioned in the comments, you can use TextMate to target intellisense tokens.

For example:

"editor.tokenColorCustomizations": {
    "[Visual Studio Dark]": {
        "textMateRules": [
            {
                "scope": "variable.other.local",
                "settings": {
                    "foreground": "#FF0000",
                }
            }
        ]
    }
}

See: https://code.visualstudio.com/docs/cpp/colorization-cpp

Share:
10,914
mellis
Author by

mellis

Updated on June 04, 2022

Comments

  • mellis
    mellis almost 2 years

    in VS Code does anyone know how to change the color theme for variable names for C++. I can change the colors for functions, comments, keywords, but I can't get variables to work. Any help would be great Thanks.