DEV Community

Jesse M. Holmes
Jesse M. Holmes

Posted on

4 Spaces or 2?

Let's pretend we aren't going to argue Tabs vs. Spaces. Is 4 spaces really more legible than 2 spaces? It seems to be the default everywhere I look, and I suspect it has to do with Tab size.

I've always preferred two spaces.

Latest comments (41)

Collapse
 
_morgan_adams_ profile image
morgana

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.

Collapse
 
qm3ster profile image
Mihail Malo

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

Collapse
 
bitbrain profile image
miguel

I always use 3 spaces!

Collapse
 
thespiciestdev profile image
James Allen
Collapse
 
jaakidup profile image
Jaaki • Edited

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.

Collapse
 
curtisfenner profile image
Curtis Fenner

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.

Collapse
 
sudiukil profile image
Quentin Sonrel

Fibonacci Indentation or nothing.

Collapse
 
kriyeng profile image
David Ibáñez

I'd vote for inverted Fibonacci Identation! 😂

Collapse
 
link2twenty profile image
Andrew Bone

That's amazing!

Collapse
 
larsklopstra profile image
Lars Klopstra ⚡

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

Collapse
 
joelnet profile image
JavaScript Joel

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.

Collapse
 
nektro profile image
Meghan (she/her)

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

Collapse
 
devhead profile image
dev-head

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.

Collapse
 
avalander profile image
Avalander

I bet you set the TV volume to odd numbers.

Collapse
 
joelnet profile image
JavaScript Joel

I use the Fibonacci sequence to set my volume.

Collapse
 
link2twenty profile image
Andrew Bone

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

Thread Thread
 
threedogs1 profile image
Three Dogs

The reason volume is adjusted in increments of 3dB is bc changes less than 3dB are imperceptible to the human ear.

Collapse
 
jsbeckr profile image
Jens Becker

3 spaces

const test = () => {
   console.log("three is the best");
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
ozzythegiant profile image
Oziel Perez

This one, officer, right here

Collapse
 
binarypatrick profile image
BinaryPatrick

Monster

Collapse
 
wolfhoundjesse profile image
Jesse M. Holmes

You rebel.