'How to edit built in code completion or snippets in vscode
Although I searched my problem before, I couldn't find any solution.
I need to find the file in which default/built-in code snippets are, and edit it. Indeed I don't know exactly is it from Python extension or the language server which is currently set to "Pylance" in my setting.
As an example, if want to implement __call__ in my class, in suggestion pop-up there is no indication that it is a snippet: (btw, I haven't defined any custom snippet)
After tab it changes to:
Which is obviously not what I want. I have to either import Any from typing module or manually delete those type hints.
clarification:
OS: Pop!_OS 21.10 x86_64
I've checked
./ms-python.vscode-pylance2022.4.2/dist/typeshedfallback/stubs/whatthepatch/whatthepatch/snippets.pyifile but it doesn't contain those.Also my
/usr/share/code/resources/app/extensions/pythondirectory doesn't havesnippetsdirectory as mentioned herePython extension version :
v2022.4.1Pylance version :
v2022.4.2
One possible solution would be to define custom code snippets and set them to be on top in the suggestion list. But I hope I could change the original one.
Solution 1:[1]
The simplest solution is probably to define a custom snippet that overrides the existing snippet for __call__ following the VS Code snippets documentation
In this case, open the command palette and locate/type Preferences: Configure User Snippets, open python.json if it already exists under Existing Snippets, otherwise type in python and select New Snippets file for 'Python'...
In your new snippets file, define a custom snippet for __call__ that's formatted the way you want, e.g.:
{
"call": {
"prefix": "__call__",
"body": ["insert your snippet guts here"],
"description": "custom __call__ snippet"
},
}
Solution 2:[2]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | JRiggles |
| Solution 2 | JL Peyret |



