DEV Community

Discussion on: Tabs vs Spaces: I have been disillusioned 🤯

Collapse
 
cappe987 profile image
Casper

There is one caveat with tab width, though. Line length. If person A uses 2-space tabs and has something indented 4 times that takes up 8 columns on screen. For person B using 8-space tabs that is now 32 columns. If you are working with a set line length, say 90 columns. Then if person A writes 90 columns, it will be far over 90 columns for person B. What fits fine on screen for person A is way off to the right for person B.

Tab width will also mess up alignment when doing line-wrapping like this (ignore the fact that I had to use all spaces because DEV does not accept tabs)

int this_is_some_function(struct some_person person1, 
                          struct another_person person2)
Enter fullscreen mode Exit fullscreen mode

For this reason, when working with the Linux kernel you should always use 8-space width tabs.

I was previously a fan of 2-space width with Use spaces instead. But after having to follow the Linux kernel standards at work I now really like 8-space width. It also helps you with not writing too long lines or too deeply nested. I'm not saying either is right or wrong, I'm still fine with using either. But is what I've learnt. Both have pros and cons.

Collapse
 
deathvenom54 profile image
Deathvenom

I see, I did not think about that....