I haven't seen the argument of accessibility tossed around here yet. I saw it a while back and it's stuck with me. Tabs have configurable width, spaces do not. If some people need deeper tabs, they can't do that with spaces.
Personally, I use spaces. I think that's because a lot of people use spaces. I'm not opposed to using tabs (they might even be more convenient for deletion using backspace/delete key).
Having both isn't necessary. We only need one. In my opinion, if we had to get remove one, it would be tabs. Spaces can't be removed so they stay. It reminds me of null and undefined in JavaScript. Two different things to do one job. It's unnecessary and can lead to bugs. Best to only have one. That's what I think 🙃
Its also possible for users to configure their editor/ide to accept a tab character as a series of individual spaces. I can't understand why more folks don't do this. They can still press their single button, but have the precision of the spaces in play.
VIM:
config file: ~/.vimrc
set tabstop=4 " The width of a TAB is set to 4.
" Still it is a \t. It is just that
" Vim will interpret it to be having
" a width of 4.
set shiftwidth=4 " Indents will have a width of 4
set softtabstop=4 " Sets the number of columns for a TAB
I feel like nowadays for this argument it's hard to take the tabs side. The advantage could have been just faster indentation but now editors convert your tabs into spaces automatically so there's really no reason at all to use tabs! Fast indentation + same interpretation across any editor = WIN! 🏆
Let's not "decide"! Use what works for your project. One project needs tabs; another needs spaces. It depends on the project goals, the development tools, and the team's needs. To make a declaration that one is objectively and unilaterally better than the other is to assume one knows all the possible projects that could ever exist.
We can not forget that Makefiles need tabs! I use spaces everywhere but I need to have my editor configured to use tabs when I am editing a Makefile.
I use both and that's the reason. Honestly, I always use the formatter in the end. So, do you remember go fmt? Yap, it converts all my spaces to tabs again.
I'm Jarod Peachey. I'm a dedicated front-end web developer with a passion for going above and beyond to create high-quality designs and UXs. Oh yeah, I know Javascript + HTML + CSS + more 👌
You can set an IDE to use the TAB button to place spaces. Takes 5 minutes and you now have the precision of spaces. I posted a quick 4 line above you can add to a VIM config. Give it a try.
I prefer the granularity of spaces, but the efficiency of tabs. So the obvious compromise is to configure your editor so that a tab generates a tab's length of spaces.
I haven't seen the argument of accessibility tossed around here yet. I saw it a while back and it's stuck with me. Tabs have configurable width, spaces do not. If some people need deeper tabs, they can't do that with spaces.
Personally, I use spaces. I think that's because a lot of people use spaces. I'm not opposed to using tabs (they might even be more convenient for deletion using backspace/delete key).
Having both isn't necessary. We only need one. In my opinion, if we had to get remove one, it would be tabs. Spaces can't be removed so they stay. It reminds me of null and undefined in JavaScript. Two different things to do one job. It's unnecessary and can lead to bugs. Best to only have one. That's what I think 🙃
I like that you only will accept total victory: in the war of spaces versus tabs, tabs must be completely annihilated
Spaces for precision. Also vim over emacs.
Its also possible for users to configure their editor/ide to accept a tab character as a series of individual spaces. I can't understand why more folks don't do this. They can still press their single button, but have the precision of the spaces in play.
VIM:
config file:
~/.vimrc
set tabstop=4
" The width of a TAB is set to 4." Still it is a \t. It is just that
" Vim will interpret it to be having
" a width of 4.
set shiftwidth=4
" Indents will have a width of 4set softtabstop=4
" Sets the number of columns for a TABset expandtab
" Expand TABs to spacesYeah, in VSCode my tab key = 2 spaces. I don't use vim as much but I'll be adding that to my config. 👍🏼
Didnt know that, saved me some effort😋
Spaces pretending to be tabs. I'm done.
I feel like nowadays for this argument it's hard to take the tabs side. The advantage could have been just faster indentation but now editors convert your tabs into spaces automatically so there's really no reason at all to use tabs! Fast indentation + same interpretation across any editor = WIN! 🏆
Tabs that gets saved as spaces.
Let's not "decide"! Use what works for your project. One project needs tabs; another needs spaces. It depends on the project goals, the development tools, and the team's needs. To make a declaration that one is objectively and unilaterally better than the other is to assume one knows all the possible projects that could ever exist.
We can not forget that Makefiles need tabs! I use spaces everywhere but I need to have my editor configured to use tabs when I am editing a Makefile.
I use both and that's the reason. Honestly, I always use the formatter in the end. So, do you remember
go fmt
? Yap, it converts all my spaces to tabs again.In different IDEs tabs are interpreted differently but spaces aren't , so its safe to use spaces.
Trend to switch from monospace to ligature might also result in tab preference.
2-4 spaces are only good in monospace fonts.
But we cannot use ligature everywhere, unlike monospace where can find in most places, so spaces will still live.
editorconfig.org/ + plugins for text editors:
indentation: spaces
size: 2
Spaces, but the golden ratio expression of depth.
spaces = ceiling(IndentLevel * 1.615)
Tabs, because instead of clicking the spacebar 2-5 times, depending on your indentation, you customize the tab width and click it once.
You can set an IDE to use the TAB button to place spaces. Takes 5 minutes and you now have the precision of spaces. I posted a quick 4 line above you can add to a VIM config. Give it a try.
I prefer the granularity of spaces, but the efficiency of tabs. So the obvious compromise is to configure your editor so that a tab generates a tab's length of spaces.
I use tabs that produce 4 or 2 spaces.
Two tabs. One tab = three spaces.
Tabs, because it's more friendly to people with visual disabilities.
But I use whatever the projects uses. Code style is the law.