How can I get VS's python syntax highlighting in VS code?

前端 未结 7 1068
终归单人心
终归单人心 2021-02-08 14:20

It seems like VS Community with python tools has a better syntax highlighting than VS Code with \"Python\" by Don Jayamanne. As you can see in the picture attached, VS Community

相关标签:
7条回答
  • 2021-02-08 14:25

    Looks like this issue has been bouncing around between maintainers of VSCode, MagicPython, and the Python extension

    A quick workaround is to simply override your color theme as instructed here. For example, if you are using Default Dark+ color theme, you can add this to settings.json:

    "editor.tokenColorCustomizations": {
        "textMateRules": [
          {
            "scope": "meta.function-call.generic.python",
            "settings": {
              "foreground": "#DCDCAA"
            }
          }
        ]
      },
    

    Now callables are highlighted correctly as seen below:

    0 讨论(0)
  • 2021-02-08 14:25

    Try MagicPython systax highlighter from extensions.

    0 讨论(0)
  • 2021-02-08 14:32

    I've tried some workarounds, but the one that worked for me was installing: Python extension for Visual Studio Code

    It comes with much more than you need, but solves the issue without patchwork.

    VS Code About: Version: 1.52.1 (system setup)

    settings.json:

    {
        "window.zoomLevel": 0,
        "workbench.editorAssociations": [
            {
                "viewType": "jupyter.notebook.ipynb",
                "filenamePattern": "*.ipynb"
            }
        ],
        "git.ignoreMissingGitWarning": true,
        "workbench.colorTheme": "Default Dark+",
        "editor.suggestSelection": "first",
        "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
        "python.languageServer": "Microsoft",
    }
    

    0 讨论(0)
  • 2021-02-08 14:34

    What did the trick for me, was to keep the Window: Auto Detect Color Scheme disabled. Attaching a picture of this checkbox in my answer:

    0 讨论(0)
  • 2021-02-08 14:35

    I ran into the same issue and some VS Code themes are not supporting syntax highlighting atleast for me. I tried with Ruby and Python and the theme I was using was Dark(Visual Studio).

    Changing to Dark+ (Default Dark) did the trick for me.

    Goto Preferences -> Color Themes and choose Dark+(Default Dark) or something similar.

    Hope it helps.

    0 讨论(0)
  • 2021-02-08 14:43

    I had problems with syntax highlighting with python in vs code and the solution was that my file name did not end with ".py"

    0 讨论(0)
提交回复
热议问题