Omar GameDev
Omar GameDev

Reputation: 11

A way to colorize the #regions in VS Code C#

I'm trying to get as comfortable as possible with this new IDE (coming from Visual Studio Community for Windows).

I used a very specific color theme that allowed me to understand the parts of the code at a glance. With VS Code though, it's more complicated for me as there aren't many options in the:

Settings > editor.tokenColorCustomizations.

Is there a way to colorize the #region pre-processor directives with a specific color?

Thanks.

Upvotes: 1

Views: 879

Answers (1)

Gama11
Gama11

Reputation: 34138

Yes, it seems it has a distinct scope name (keyword.preprocessor.region), allowing you to target it with the setting, as the Developer: Show TM Scopes command shows:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "keyword.preprocessor.region.cs",
            "settings": {
                "foreground": "#FF0000"
            }
        },
        {
            "scope": "keyword.preprocessor.endregion.cs",
            "settings": {
                "foreground": "#FF0000"
            }
        }
    ]
}

It seems the scope includes neither the # nor the string though:

Upvotes: 1

Related Questions