Reputation: 51
I want to use 2 spaces for indentation in Visual Studio Code (version 1.38.1) for Python (Other languages as well but for now Python). However, when auto formatting (on save and using Shift Alt F) it changes it to 4 spaces.
I have set it up so that 2 spaces are used and I can see this in my settings and in the bottom right hand corner.
Here are my settings:
{
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"editor.tabSize": 2,
"editor.formatOnPaste": true,
"window.zoomLevel": 0,
"workbench.colorTheme": "Visual Studio Light",
"editor.codeLens": false,
"editor.formatOnType": true,
"editor.formatOnSave": true
}
I have also updated the config.py file
prefs['indent_size'] = 2
I have 3 extensions, Python, C# and yo.
I have trawled the internet to no avail, any help would be greatly appreciated!
Upvotes: 5
Views: 5862
Reputation: 16000
None of the formatters supported by the Python extension to my knowledge read VS Code's setting for formatting. You will need to configure the formatter directly to have it keep a 2 space indent (which will vary from formatter to formatter, including not even being configurable if you chose black).
Upvotes: 1