Whenever I let vscode autoformat my code, it formats to 2 spaces instead of 4, even though apparently the default is 4 spaces, and I have not touched the settings.json
Editor.tabsize also shows 4.
In the bottom right hand corner, its shows spaces: 4, but after autoformatting, it shows spaces: 2, and will revert itself back to 2 no matter how many times I change it to 4.
Anyone know what's going on. This is happening with Ruby, if that matters.
Also, does anyone know of an alternate indenter/autoformatter for VScode?
You can open the settings.json file with the Preferences: Open Settings (JSON) command in the Command Palette (Ctrl+Shift+P). Once the file is open in an editor, delete everything between the two curly braces {} , save the file, and VS Code will go back to using the default values.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With