使VSCode变量具有颜色

时间:2017-12-09 02:19:40

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

我想用颜色显示变量。

它的外观如下:

Python

这就是我想要的:

Variable Colored

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

3 个答案:

答案 0 :(得分:2)

在settings.json中尝试此设置:

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

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

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

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

答案 1 :(得分: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"
        }
      }
    ]
}

答案 2 :(得分:0)

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

<强> SomeTheme.json

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

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