VSCode:用户设置中的 TextMate 正则表达式

问题描述 投票:0回答:1

我正在尝试更改主题以更适合我的日常使用,但在尝试自定义特定单词或模式时遇到一些麻烦。

我现在正在使用这种格式;

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

是否可以格式化特定的关键字或模式而不是范围?

regex visual-studio-code formatting textmate
1个回答
4
投票

要将语法突出显示应用于特定关键字和其他语言结构,您需要编写带有语法的扩展来解析该语言的语法。当您编写此类扩展时,您还定义了每种语言构造的范围。

例如,在语言支持扩展中,我可能会匹配关键字

function
并为其指定范围
entity.name.function
:

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

作为最终用户,您可以覆盖主题为范围着色的方式,但您无法更改语言支持将范围分配给语言构造的方式。

TL;DR:不,你不能。

© www.soinside.com 2019 - 2024. All rights reserved.