markdown guide
 

I prefer 4 spaces because they take up more screen space, which means that I can fit fewer indentation levels before it starts to feel uncomfortable, so in general it means that I start addressing some potential spaghetti code issues earlier.

(although tabs are better because anybody can configure their editor to show as many or as few spaces as they want to, I had to say it)

 

The argument about "how many spaces" is really an argument in favour of tabs.

It goes beyond how many as well, since the moment you use spaces, you start having people align code with them as well. :/

 

vs code can auto format an entire file to use the number of spaces one desires, and always uses spaces

Yeah but at my work we use two spaces, can I configure vscode to display four spaces but actually save the file with two?

not that I'm aware of. you'd just have to change it before you commit

Auto-formatting causes trouble with source control. You end up having large patch-sets than desired. It can be hard to locate what was actually changed in a file.

 
 

We will argue 4 vs 2 spaces until we are blue in the face. God forbid someone to suggest a compromise of 3 spaces, for they will be murdered before they finish their sentence.

3 spaces is the most logical compromise. But because humans are illogical, we'll never see a 3 spaced code file.

 
 
 

I think you'll find the volume should be changed in increments of 5... 😉

 

how dare you suggest we do something that is not a multiple of 2?? /s

 

we tried that at a previous gig; made everyone unhappy and uncomfortable. if it's code, IMHO, it's a tab (4 spaces!); if it's markup or documentation or config, two is perfect.

 
 

Tabs, people, use tabs. Then you can choose however many spaces you wish.

 

I started contributing to a project last night, and after asking this question an issue appeared a few hours ago that is pretty relative to your point!

Tabs are breaking YAML

 

This is unfortunate that YAML chose not to accept tabs. There's no practical reason not to allow it.

 

In VSCode there are options like setting the tabs equal to a number of spaces, or you can even have tab insert spaces, I believe.

In other words, I’m not sure what you mean. 😂

 

If the line starts with the tab character, I can configure VS Code to show it as either two or four (or any other number) spaces, so the same code can have different indentation space in your machine than in mine.

If I configure VS Code to set two spaces every time I press tab, it is unfortunately not possible for somebody who prefers four spaces indentation to visualise the code that way.

This is the first time any part of this discussion has made sense to me. 🤩

 

or use vs code and still be able to pick the number of spaces you want

 

Am I the only person that Bracket Pair Colorizer just annoys and distracts?
I'm not sure if I should set violent colors or something, but any time I try it it only harms me.
I just have "editor.renderWhitespace": "boundary" and the default indent guides and it seems enough for me.
Ditto for Indenticator and indent-rainbow.
indent-rainbow also doesn't autodetect the tab settings, which are a builtin VSCode thing, why this :v

 

8

I used to prefer 4, but I figured, if I find myself indenting too much, then it should probably be refactored. Sort of learned about this by reading about the Linux style guide.

 

My preference for 4 spaces comes from starting out with Python.

Since starting to use Prettier in VS Code, I've been having issues with the setting being changed to 4 spaces in the interaction with the Rainbow Indent extension, and as such have been moving to using 2 space instead.

I don't think either is "more readable" than the other. When there's a bunch of indent widths, even the rainbow indent/bracket colorizer isn't enough to stop me from needing to use my finger/piece of paper to figure out where the matching curly brace is/should be.

 

Oh god, that question will break us all.

Golden Ratio, the deeper you go, the more space, as well as above and below.

Until your code turns around on itself, then you're next level...

Does depend on the font though, monospace, bold etc.

 

I prefer four because its much easier to quickly scan for what braces match and where blocks end and begin.

Deeply nested code is usually to be avoided, so I don't miss the space is takes up.

 

I use 4 for Python code (it's PEP8) and 2 for html/css/js.

 

Either works for me.

It's when I have to open up some C or Java that has mixed spacing that I start spewing profanities.

 

I doubt anybody has done actual research on which is more legible, though I assume whatever one is used to will be the most legible to them.

 
 
 

Most often I use 2 spaces, but it really depends on the language. And I auto refactor tabs to spaces ;)

 
 
Classic DEV Post from Mar 9

What’s an unpopular software opinion you have?

Please share! ...

Jesse M. Holmes profile image
⛵️ Building ambulatory healthcare software in beautiful, historic Annapolis, Maryland. Brass-bander. ADHD Avenger. Lover of giant hounds. Believer in the impossible.
Join dev.to

The fastest growing software community.
Free forever.