1

I don't know how many projects I've seen with this kind-of-hard-to-read formatting, and I'm not finding the answer online as to why Microsoft made 2-space indents a default, but to me it's kind of ruining projects until I figure out how to get VS Code or other editors to display 2-space indents as 4-spaces or 4-column tabs (but still save to 2-space indents).

Does anyone know why VS Code was set to default to this? Also any advice on how to config the editor to display the indents as 4-column tabs while still saving as 2-space indents would be great.

user8865053
  • 101
  • 2
  • 11
  • Check the settings and type `indent` in the search. Is not that hard to make a question here. – MikeVelazco Nov 07 '17 at 18:46
  • 1
    Not sure that's really an answer or what you mean by your second sentence there Mike, but I played with the `indent` settings and it doesn't appear to do what I need. It saves whatever it ends up showing in the file (which I can see with "editor.detectIndentation": true) no matter what I type (even if it converts x spaces to a tab), and I need the indents (2 or 4 spaces, whatever I set it to for the project) to display/function as tabs but save as spaces, so maybe the question was misunderstood here. – user8865053 Nov 08 '17 at 20:31
  • 2
    Possible duplicate of [visual studio code change indentation](https://stackoverflow.com/questions/34174207/visual-studio-code-change-indentation) – Lee Goddard Feb 12 '18 at 12:43
  • This question seem to be answered by [this response](https://stackoverflow.com/questions/34174207/visual-studio-code-change-indentation). – Lee Goddard Feb 12 '18 at 12:44
  • Horizontal space is valuable. 4 spaces is just a waste. Then again, this is one of the most opinionated subjects in programming and no amount of rational reasoning will arrive at a solution. – Vik Mar 02 '18 at 10:24
  • "why Microsoft made 2-space indents a default" - for what language? Microsoft doesn't mandate coding standards for any languages except, say, C# which has 4 spaces standard. – Kos Jul 20 '18 at 17:31
  • Downvoting your question because the "why" is not important. You need to refine your question to be more productive and state what you are trying to accomplish. – JGallardo Oct 07 '19 at 13:29

2 Answers2

4

click this you will have all the options.

enter image description here

Anwar Hossain
  • 654
  • 6
  • 21
  • 1
    That lets me change the options easily but they don't appear to do what I need, so I'm assuming VS Code can't do that yet, and I'm really surprised why as I see a very large business usage and need for it to save a lot of time and headache (believe me when you start seeing inadvertent line change commits or conflicts from devs who didn't realize or care that their code was auto-changing indents due to their editor settings or auto-formatting). – user8865053 Nov 08 '17 at 20:33
3

I did it by changing the option "Tab Size" to 4 and unchecking the option "Detect Indentention"