VSCode autoformat going to 2 spaces instead of 4

For those who could not use above like me, Here is somewhat GUI guide.

Go to setting by pressing = > CTRL + , (suggested by comment) to open settings or via menue

File->Preferences->Settings   

There you can find both (find tab size and detect indentation) in search box, like I have shown in following image (see the text 'lets play')

detect indentation => uncheck it (turn off)

tab size => Set it to 4

How to ? need to visualize? here it is,

Right click following image and open in new tab see it clearly

enter image description here


I think that you might have a problem with "Auto Detect Indentation". You should try to turn it off and see if that helps.

// The number of spaces a tab is equal to. This setting is overriden based on the file contents when `editor.detectIndentation` is on.
"editor.tabSize": 4,

// When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
"editor.detectIndentation": false