【问题标题】:vscode textmaterule to target react className stringvscode textmaterule 以反应类名字符串为目标
【发布时间】:2021-12-31 14:15:59
【问题描述】:

找到这篇关于如何dim semicolons in vscode 的精彩帖子。

认为在使用诸如尾风之类的类实用程序时,javascriptreact 和 typescriptreact 文件对 className 字符串执行相同的操作可能很有用。

有人知道解决这个问题的方法吗?


如果在 j/tsx 元素聚焦时可以忽略该规则,那将是锦上添花。

【问题讨论】:

  • 找到您要更改的元素的 TextMateScope 并修改您的设置,这里有足够的帖子来查找

标签: visual-studio-code vscode-settings syntax-highlighting


【解决方案1】:

替代(无需扩展)解决方案将是

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": "string.quoted.double.tsx",
        "settings": {
          "foreground": "#ffffff77"
        }
      }
   ]

问题在于它的目标范围太广,而不仅仅局限于className 内的string.quoted.double.tsx。

【讨论】:

    【解决方案2】:

    发布后继续搜索 SO(如 @rioV8 建议的那样)并找到 this SO 答案以引导我接近目标。

    安装了highlight extension 并写了这个:

      "highlight.regexes": {
        "(.*\\sclassName=\")(.*?)\"": [
          {},
          {
            "color": "grey"
          }
        ]
      }
    

    【讨论】:

    • 有几个相互冲突的扩展,一开始看起来好像不起作用,但实际上效果很好。
    猜你喜欢
    • 1970-01-01
    • 2017-07-20
    • 1970-01-01
    • 2018-10-26
    • 2013-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-29
    相关资源
    最近更新 更多