使 VSCode 变量具有颜色

Mod*_*mat 5 python syntax-highlighting visual-studio-code

我想让变量用颜色显示。

这是它的外观:

Python

这就是我想要的样子:

可变颜色

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

Mar*_*ark 9

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

 "editor.tokenColorCustomizations": {
    "variables": "#f00"
 },
Run Code Online (Sandbox Code Playgroud)

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

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

"editor.tokenColorCustomizations": {
  "textMateRules": [
    {
      "scope": "comment",
      "settings": {
        "fontStyle": "italic",
        "foreground": "#C69650"
      }
    }
  ]
},
Run Code Online (Sandbox Code Playgroud)


小智 6

这对我有用。据我所知,它使它看起来像默认的 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"
        }
      }
    ]
}
Run Code Online (Sandbox Code Playgroud)


l'L*_*L'l 0

您应该能够添加颜色来自tokenColors定义颜色(基本示例):

一些主题.json

{ 
 "name": "Some Theme",
 "type": "dark",
 "colors": {
 ...
},
"tokenColors": [
   {
    "name": "Variables",
    "scope": "variable",
    "settings": {
    "foreground": "#e06c75"
   }
  },
 ]
}
Run Code Online (Sandbox Code Playgroud)

我没有,尽管从另一个主题 JSONVSCode来看它看起来很相似。