In VS Code, you can indent in several places:
- General / Workspace options (bottom line),
- User settings
- Language formatting settings.
When using Python, no matter what settings you set, they are all overridden by the autopep8Args value of the autopep8Args parameter to format a language whose size is not 4.
By default, autopep8 used as the VS Code Python code formatter, but there are others like yapf .
To update the indent size of this formatting, search your user settings for "python.formatting.autopep8Args" and set it: ["--indent-size = 2"],
"python.formatting.autopep8Args": ["--indent-size=2"],
source share