自定义VSCode中`backquotes`内文本的颜色 [英] Customize color of text inside `backquotes` in VSCode

查看:105
本文介绍了自定义VSCode中`backquotes`内文本的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以找到在Visual Studio Code中处理自定义颜色的唯一选项是:

The only options I can find that deal with custom coloring inside Visual Studio Code are those:

"editor.tokenColorCustomizations": {
    "[Atom One Dark]": {
        "comments": "#FF0000" // only 6 color-customizable
    },
    "workbench.colorCustomizations": {
        "statusBar.background": "#666666",
        "panel.background": "#555555",
        "sideBar.background": "#444444"
    },
},

是否可以为这些类型的事物设置自定义颜色?存在一个用于注释和字符串的字符串(在 string 内部)。我相信其他使用正则表达式的东西也应该有类似的可能。

Is there a way to set a custom color for these types of things? One exists for comments, for strings (inside "string"). I believe something similar should be possible for other stuff using regexps. Thanks in advance.

推荐答案

搜索 tokenColorCustomizations textMateRules ,您会发现您可以执行以下操作(请参见使用文本伴侣着色):

Search for tokenColorCustomizations and textMateRules and you will find that you can do something like this (see colorizing with textmate):

"editor.tokenColorCustomizations": {

    "textMateRules": [
      {
            // works for a language that recognizes backticks as string templates
        "scope": "string.template",
        "settings": {
          "foreground": "#FF0000"
        }
      },
      {
       "scope": "punctuation.definition.template-expression.begin, punctuation.definition.template-expression.end",
       "settings": {
         "foreground": "#F0F"
       }
      },
    ]
}

使用 Inspect TM范围... 命令面板中的命令。因此,我使用该命令在模板文字内部单击,并获得了 string.template.js.jsx 范围。但这并没有改变$ {someVar},因此我检查了该范围并看到 variable.other.readwrite.js.jsx 以及其他范围参数-仍在隔离

using the Inspect TM Scopes... command in the command palette. So I used that command to click inside a template literal and got the string.template.js.jsx scope. But that didn't change the ${someVar} so I inspected that scope and saw variable.other.readwrite.js.jsx plus additional scope parameters - still working on isolating that kind of a variable from other variables.

编辑:应该仅使用 string.template 处理更多文件类型,如果语言将反引号作为字符串模板。

Should work in more file types by using only string.template, if the language treats backticks as a string template.

您也可以在设置中更改 fontStyle 。关于使用 TM范围命令,这里有一些答案。

You can also change the fontStyle within a setting. There are a few answers here about using the TM Scopes command.

这篇关于自定义VSCode中`backquotes`内文本的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆