VS Code:改变变量的颜色?

VS Code: Change color of variables?

我使用 VS Code,想更改 Python 代码中变量的颜色。我读到我必须添加

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

到 settings.json 文件。我已将它添加到我打开的文件夹中的 settings.json,并且还尝试将它附加到全局 settings.json 文件。但是 none 有效。

现在我不知道还能尝试什么。 有人知道怎么做吗?

编辑:

这是来自本地 json 文件的代码:

{
    "python.pythonPath": "C:\Users\JannR\AppData\Local\Programs\Python\Python39\python.exe",
    "workbench.colorCustomizations": {
        "activityBar.background": "#131a29",
        "titleBar.activeBackground": "#A4BD00",
        "titleBar.activeForeground": "#000000",
        "titleBar.inactiveBackground": "#c4d16e",
        "titleBar.inactiveForeground": "#000000",
        "minimapSlider.background": "#a4bd003a",
        "minimapSlider.hoverBackground": "#a4bd004d",
        "minimapSlider.activeBackground": "#a4bd0060",
        "scrollbarSlider.hoverBackground": "#a4bd001f",
        "scrollbarSlider.activeBackground": "#a4bd0033",
        "scrollbarSlider.background": "#a4bd000e",
        "editorGroup.border": "#A4BD00",
        "editorGroup.dropBackground": "#a4bd0060",
        "editorGroupHeader.tabsBorder": "#a4bd0060",
        "tab.activeBackground": "#a4bd002a",
        "tab.activeBorder": "#000000",
        "tab.unfocusedActiveForeground": "#5b6350",
    },
    "editor.tokenColorCustomizations": {
        "variables": "#ff0000",
    }
}

这里来自全球:

{
    "workbench.editorAssociations": {
        "*.ipynb": "jupyter-notebook"
    },
    "tabnine.experimentalAutoImports": true,
    "editor.cursorStyle": "block-outline",
    "workbench.iconTheme": "vscode-icons",
    "vsicons.dontShowNewVersionMessage": true,
    "auto-close-tag.fullMode": true,
    "auto-close-tag.SublimeText3Mode": true,
    "liveServer.settings.donotVerifyTags": true,
    "liveServer.settings.donotShowInfoMsg": true,
    "prettier.singleQuote": true,
    "explorer.confirmDelete": false,
    "python.pythonPath": "C:\Users\JannR\AppData\Local\Programs\Python\Python39\python.exe",
    "explorer.confirmDragAndDrop": false,
    "workbench.startupEditor": "newUntitledFile",
    "[python]": {
    
        "editor.wordBasedSuggestions": false
    },
    "python.showStartPage": false,
    "workbench.tips.enabled": false,
    "notebook.cellToolbarLocation": {
        "default": "right",
        "jupyter-notebook": "left"
    },
    "python.defaultInterpreterPath": "C:\Users\JannR\AppData\Local\Programs\Python\Python39\python.exe",
    "workbench.colorTheme": "FireFly Pro",
    "window.title": "${activeEditorShort} - ${folderName} - ${appName}",
    "workbench.colorCustomizations": {
    

        "titleBar.activeBackground": "#0000ff",
    },
    "editor.tokenColorCustomizations": {
        "variables": "#ff0000",
    },
    "vs-color-picker.autoLaunchDelay": 10,
    "windowColors. DeleteSettingsFileUponExit": true
}

编辑 V2:

Screenshot of variable description

这样的支票可以吗?它在我的电脑上运行良好。

更新:

您正在使用 FireFly Pro 的主题。 "variables": "#ff0000" 似乎不起作用,而在使用其他一些主题时它会起作用。这是因为当您使用不同的颜色主题时,变量在不同的范围内。

例如:

Dark+的主题(打开命令面板:检查编辑器标记和作用域):

FireFly Pro的主题:

所以如果想在FireFly Pro颜色主题下修改,可以这样自定义:

"editor.tokenColorCustomizations": {
        "textMateRules": [
          {
            "scope":"source.python",
            "settings": {
              "foreground": "#00fff2",
              "fontStyle": "bold"
            }
          }
        ]
      },