【问题标题】:Make VSCode Variables have Colour使 VSCode 变量具有颜色
【发布时间】:2018-05-23 07:25:57
【问题描述】:

我想用颜色显示变量。

看起来是这样的:

这就是我想要的样子:

查看here,我找不到任何允许我更改此设置的设置。

【问题讨论】:

    标签: python visual-studio-code syntax-highlighting


    【解决方案1】:

    在你的 settings.json 中试试这个设置:

     "editor.tokenColorCustomizations": {
        "variables": "#f00"
     },
    

    有一些这样的简单标记颜色自定义可用:变量、cmets、关键字、函数、数字、字符串和类型。那些只允许设置 color

    如果您使用“textMateRules”,您可以设置更多属性。例如:

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

    【讨论】:

    • 感谢您,它适用于某些事情,但并非所有事情。例如,this 显示变量 self 变为红色,但 search_obj 不是,get_key 部分也不是,它应该应用函数 - 该函数仅适用于定义.
    • 你也可以试试stackoverflow.com/questions/47272835/…更详细的范围可能会帮助你实现你想要的。
    【解决方案2】:

    这对我有用。据我所知,它使它看起来像默认的 Javascript 格式。

    settings.json

    "editor.tokenColorCustomizations": {
        "textMateRules": [
          {
            "scope": "meta.function-call.generic.python",
            "settings": {
              "foreground": "#DCDCAA"
            }
          },
          {
            "scope": "source.python",
            "settings": {
              "foreground": "#9CDCFE"
            }
          },
          {
            "scope": "punctuation.definition.string.begin",
            "settings": {
              "foreground": "#ce9178"
            }
          },
          {
            "scope": "punctuation.definition.string.end",
            "settings": {
              "foreground": "#ce9178"
            }
          },
          {
            "scope": "punctuation",
            "settings": {
              "foreground": "#dfdfdf"
            }
          }
        ]
    }
    

    【讨论】:

      【解决方案3】:

      您应该可以在tokenColors 中添加颜色以自定义颜色(基本示例):

      SomeTheme.json

      { 
       "name": "Some Theme",
       "type": "dark",
       "colors": {
       ...
      },
      "tokenColors": [
         {
          "name": "Variables",
          "scope": "variable",
          "settings": {
          "foreground": "#e06c75"
         }
        },
       ]
      }
      

      我没有VSCode,虽然从another themes JSON 看起来很相似。

      【讨论】:

        【解决方案4】:

        试试这个:

        {
                    "scope": [
                     "variable.other.readwrite", 
                     ],
                     "settings": {
                     "foreground": "#ffffff",
                     }
                },
        

        【讨论】:

          猜你喜欢
          • 2020-12-01
          • 2023-03-05
          • 1970-01-01
          • 2022-01-01
          • 1970-01-01
          • 2023-01-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多