Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode: TextMate Regex in User Settings

I'm trying to alter a theme to be more suitable for my daily use but I'm having some trouble trying to customize a specific word or pattern.

I'm using this format at the moment;

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "comment",
            "settings": {
                "foreground": "#ff0000",
            }
        },
    ]
}

Is it possible to format specific keywords or patterns rather than scopes?

like image 754
Darren A. Avatar asked Sep 03 '25 03:09

Darren A.


1 Answers

To apply syntax highlighting to specific keywords and other language constructs you need to write an extension with a grammar to parse the syntax for the language. When you write such an extension you also define the scope for each language construct.

For example, in a language support extension I might match the keyword function and give it the scope entity.name.function:

<key>FunctionKeyword</key>
<dict>
    <key>match</key>
    <string>function</string>
    <key>name</key>
    <string>entity.name.function</string>
</dict>

As an end user you can override how your theme colors a scope, but you don't have a way to change how the language support assigns a scope to a language construct.

TL;DR: no, you can't.

like image 58
Matt Avatar answered Sep 04 '25 22:09

Matt