Search code examples
c++visual-studio-codesyntax-highlighting

Visual Studio Code: Theme One Monokai: Change / Custom Highlight Color for C/C++ `const`


I am using the (amazing) One Monokai theme in visual studio code. One thing that bothers me is that variable modifers like const and control flow like for, if, while, ... are displayed using the same color. Based on this tutorial, I tried a custom coloring by adding to settigs.json:

"editor.semanticTokenColorCustomizations": {
        "[One Monokai]": {
            "rules": {
                "<KEYWORD>": {
                    "foreground": "#A2142F"
                }
            }
        }
    }

I tried multiple <KEYWORDS> listed here, where I expected either readonly or property to work. I tried a different, unambigious, keyword, e.g. variable - that worked as expected, so the general "frame" is working.

Any idea what keyword has to be? Or do I have to make a workaround using a third party package for specific word highlighting?


Solution

  • With the comment pushing me into the right direction and this tutorial, the working code is

    "editor.tokenColorCustomizations": {
        "[One Monokai]": {
            "textMateRules": [
                {
                    "scope": "storage.modifier.specifier.const.cpp",
                    "settings": {
                        "foreground": "#A2142F"
                    }
                }
            ]
        }
    }