11

I'm currently using VSCode and I have this problem. I want to set the space size equals to 1 and tab size equals to 2 as default for every project. But it still set back as spaces: 4 for every project. And as I set the spaces = 2, and run Beautify file. Everything looks good with space = 2. Then I hit save it format my file to indent size 4. How do I set it as default equal to 2 guys?

Still Spaces: 4

even I change in User settings

enter image description here

1
  • Do you have an option which convert tabs to spaces? Commented Mar 13, 2017 at 10:09

2 Answers 2

15

By default VSCode try to detect indent option for a file. So set editor.detectIndentation to false

// When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents. "editor.detectIndentation": false, 
Sign up to request clarification or add additional context in comments.

Comments

2

EditorConfig is a handy standard for establishing project wide formatting options: http://editorconfig.org.

There's a VSCode extension supporting it: https://github.com/editorconfig/editorconfig-vscode

This doesn't directly answer your question, but it works well. And if you switch editors, you still can keep your formatting standard by getting each editor's plug-in for EditorConfig.

2 Comments

How do we config the EditorConfig settings in VSCode?
Just install the extension and create its config file as described here: editorconfig.org.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.