

Add the following to your json script (remember fields need to end with a comma, if it is followed by another field)Ĭhanging the number "4" to the number of spaces you wish to use for indentation.Luckily the fix is simply turning this off by adding "tectIndentation" : false to the global or language settings in addition to the values specified by the accepted answer. And this causes a major problem if the auto detection believes it has to indent in a way that does not conform with your user settings. Visit our Github page to see or participate in PTVS development. This is because vscode will also try to "detect indentation". Python Tools for Visual Studio is a completely free extension, developed and supported by Microsoft with contributions from the community.

So having had a wrong indentation once, one can experience that the suggested answer does not work within the language. Download Visual Studio Code Free and built on open source. Some extensions do not choose indentation but others do, and what's worse is that vscode seem to "remember" indentation within a file. Download Visual Studio Code - Mac, Linux, Windows Version 1.71 is now available Read about the new features and fixes from August. This command is convenient for testing just a part of a file. The problem most likely stems from the fact that vscode and their extensions decide themselves how to indent code. Right-click anywhere in the editor window and select Run Python File in Terminal (which saves the file automatically): Select one or more lines, then press Shift+Enter or right-click and select Run Selection/Line in Python Terminal. For anyone still facing a problem, and finding that the default answer did not solve your problem, here is a method based on this discussion/issue on the vscode github.
