VS代码:更改变量的颜色?

2024-03-29 11:09:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用VS代码,并希望更改Python代码中变量的颜色。我读到我必须补充的内容

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

转到settings.json文件。我已将其添加到我打开的文件夹中的settings.json中,并尝试将其附加到global settings.json文件中。但这些都不起作用

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

编辑:

以下是本地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


Tags: 文件代码jsonfalsetruesettingsvariablesusers
1条回答
网友
1楼 · 发布于 2024-03-29 11:09:25

我可以要一张这样的支票吗?它在我的电脑上运行得很好

enter image description here

enter image description here

更新:

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

例如:

{}的主题(打开命令调色板:检查编辑器标记和范围):

enter image description here

{}的主题是:

enter image description here

因此,如果您想在FireFly Pro颜色主题下对其进行修改,可以按如下方式对其进行自定义:

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

相关问题 更多 >