I wanted to see what everyone here used. I heard in languages like Haskell, spaces are a must. In Makefiles, TABS are a must.
But let's talk about our personal preference! Mine personally is 2 spaces. I feel like the code is easier to read. However, in my IDE, I press the Tab button to create the 2 space indentation.
So what do you prefer?
To be honest, once I preferred tabs, anyway tabs are uncommon practice in the open source world, compared on how it looks the poll, that forced me to use 4 spaces instead.
It's not a big problem today using a good IDE and EditorConfig setting files.
I'm so surprised tabs is so popular; I always thought 4 spaces is the common standard (in a general, overall, way). I use 4 spaces.
For complete clarity, I'll just point out that the tab key is not related to how you indent (tabs vs. spaces). We can/would use the tab key in either case.
Anyway, the thing with tabs is that it's not shown the same for everyone, and it's basically the only reason I choose spaces over tabs, if I can. As a top of my head example, for code written like this:
someFunctionSomewhere(passing,
all,
sorts,
of,
things)
Tabs can potentially be annoying here. Person that wrote it had to use let's say, 6 extra tabs to format like that (because for that person a tab is about 4 spaces), but when someone else tries to read it, and they have a different setting for tabs (maybe they prefer 8 spaces for a tab, or 2), suddenly it shows up weird, might even need to scroll to read it.
So yeah, that's the only thing about it for me. Spaces basically fix that kind of issue. However, it doesn't beat established guidelines and such, as others pointed out. (Though it might be a valid reason to start a discussion about adopting a spaces style. :) )
I think it depends on the ecosystem. e.g. Ruby guidelines is to write with 2 spaces. And consistency is important.
For HTML, JS and CSS I switched a couple of years ago from tabs (that show 4 spaces) to 2 spaces. I still use the tab key, Sublime Text converts it to 2 spaces. More and more web open source projects adapted 2 spaces. It has become a standard, and if you can't beat them, join them.
Same for JS camelCase, CSS dash-case, ruby snake_case, react PascalCase. Do whatever is the standard in the ecosystem.
Tabs that's rendered to 3 spaces. GitHub renders tabs to 8 spaces by default and that's so annoying.
4 Spaces here! But whatever you use, the most important thing is to follow a convention, and not have people commit masses of whitespace change. Horrible!
I think most people use Tabs. It gives ample amount of spaces in one key press.
Asko Nõmm
Web Developer & Designer
I prefer tabs, but I always set them up so it's the same as 2 spaces in size.