Highlight Python user function calls in Visual Studio Code (vscode) Default Dark + theme

Introduction

Since the function name and argument name when calling the user function of the Python program (* .py) were not highlighted in the default theme (Default Dark +) of Visual Studio Code (1.49.2), add the settings to "settings.json". By doing so, it can be displayed.

Operation image

Before adding settings

The name (eg print_debug) and arguments when calling the user function are not highlighted. 20200925.png

After adding settings

It will be highlighted. 20200925_2.png

How to add settings

  1. Open the Visual Studio Code menu "File"-> "Preferences"-> "Settings"
  2. Open the tree menu "Workbench"-> "Appearance" and open "Edit in settings.json" of the item "Color Customizations". 20200925_3.png
  3. Add the following code to the opened "settings.json"

settings.json


    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": [
                    "meta.function-call.python",
                ],
                "settings": {
                    "foreground": "#dcdcaa"
                }
            },{
                "scope": [
                    "meta.function-call.arguments.python",
                ],
                "settings": {
                    "foreground": "#9cdcfe"
                }
            },{
                "scope": [
                    "punctuation.definition.list.begin.python",
                    "punctuation.definition.list.end.python"
                ],
                "settings": {
                    "foreground": "#fff"
                }
            }
        ]
    }
  1. Save "settings.json" by overwriting and check the display of the Python program. If the existing settings are written in "settings.json", be careful not to conflict the settings.

If the highlight is not displayed even after updating the settings, check the following points. --Incorrect addition of "settings.json". Is it in JSON format? Is there a conflict with the existing settings? --Are you editing "settings.json" in "Color Customizations"? --Is the extension of the Python program * .py? --Are there any conflicts with Extensions?

Change highlight target

The highlight target is specified by "scope". By changing the value specified for this "scope", the highlight target will also be changed.

  1. Investigate the value specified for "scope"
    Open the command palette (Win: Ctrl + Shift + P, Mac: ⌘ + Shift + P) and execute "Developer: Inspect Editor Tokens and Scopes". 20200925_4.png
  2. A mini window is displayed in the text where the cursor of the editor is located, and the value displayed in "textmate scopes" in the window is specified in "scope" of "settings.json". 20200925_5.png

Recommended Posts

Highlight Python user function calls in Visual Studio Code (vscode) Default Dark + theme
Settings for Python coding in Visual Studio Code
Python development in Visual Studio 2017
Python development in Visual Studio
Do something like a Python interpreter in Visual Studio Code
Bash, Python, Javascript, code command, etc. in Visual Studio Code on Mac
Installation of Visual studio code and installation of python
Run Python in C ++ on Visual Studio 2017
Create a Python development environment in 10 minutes (Mac OS X + Visual Studio Code)
Build Python development environment with Visual Studio Code
Run Python YOLOv3 in C ++ on Visual Studio 2017
Time when terminal disappears in Visual Studio Code
[Visual Studio Code] [Python] Tasks.json + problemMatcher settings for Python
Translator in Python from Visual Studio 2017 (Microsoft Translator Text API)
App development to tweet in Python from Visual Studio 2017
Make Visual Studio Code autocomplete for python external libraries
Python development environment with Windows + Anaconda3 + Visual Studio Code
Python development environment with Windows + Python + PipEnv + Visual Studio Code
Until you run server Django in Visual Studio Code
Japanese output when dealing with python in visual studio
AWS SDK for Python (Boto3) development in Visual Studio 2017
[Visual Studio Code] [Python] [Windows] Support for garbled Japanese characters in Python in VS Code task / debug output
How to use linux commands in Visual Studio Code terminal
Set up a Python development environment with Visual Studio Code
How to debug the Python standard library in Visual Studio
Enable the virtualenv Python virtual environment for Visual Studio Code
Install python and Visual Studio Code on windows10 (April 2020 version)