4 ms·
My editor and IDEs convert tabs to spaces...
by tffgg 5y ago
My editor and IDEs convert tabs to spaces...
- orangepanda 5y agoNo one actually presses spacebar 4 or 8 times... Tabs, however, are superior - everyone can use the indentation they prefer without causing conflicts.
- mosselman 5y ago> everyone can use indentation they prefer without causing conflicts. To be honest, I never thought of this, I use spaces and my editor converts to 2-space indentation. But I can imagine that some people prefer 4 "space" indentation. With spaces this is impossible, whereas I now realise, an editor can render them any way it wants, so at 2 'spaces'. So I agree somewhat, that tabs sound good on paper. But then again, I don't want to start earning less all of a sudden...
- eloisius 5y agoIn theory I agree, but having recently worked in a code base that used tabs, it was painfully obviously that some devs displayed them as 4 spaces and some as 2 because they would visually align things for their editor’s configuration. It was very ugly.
- cjfd 5y agoThat is why one should use tabs for indentation and spaces for alignment. Then this problem does not occur.
- pjmlp 5y agoJust like with C and static analysers, there is the "one should" and what the large majority actually ends up doing, as usually no one enforces anything on large code bases in most development shops.
- j1elo 5y agoJust like the ethos "If the backup process is not automatic, it won't happen", I'd like to propose "If the formatting style is not already enforced by default, there is no formatting style".
- kstenerud 5y agoThe moment you begin talking about "should", everything goes out the window because humans will thwart you. The only way to be 100% sure is to avoid multi-space characters like tab in the first place.
- eloisius 5y agoNah that’s exactly how the alignment did occur. Spaces would be mixed with tabs to align things with 4 spaces aligning to each tab. Since I don’t like to view 3 virtuously splits I don’t like all the wasted indentation space and I view tabs as 2 spaces. It was obvious when someone didn’t consider how it would like if a tab wasn’t 4 spaces.
- throwawayffffas 5y agoMy personal preference to solving this problem is a simple rule. "No alignment allowed.", Then you only need to worry about indentation, and the character used does not matter.
- pjmlp 5y agoIn theory, assuming the files are always opened by the same tool and no one ever types a single space instead of a tab. After fixing a couple of mixed tabs/space files back in the glory MS-DOS days, I became a space zealot. Apparently it was a good decision.
- globular-toast 5y agoNope... This is the big misunderstanding that, for some reason, people just don't get and causes tabs to be maligned. Tabs are for indentation, not for alignment. If you want to align things within the same indentation level, use spaces. This will never break on any platform or in any editor. When I was about 5 years old I ate a parsnip thinking it was a potato. My taste buds were all of a sudden overwhelmed and I spat it out in disgust. It took more than 20 years for me to try a parsnip again. My theory is the same with tabs. Everyone developer, during their early career, learns what tabs are the hard way, that is when they open a document in another editor and, because they've made a mistake, it looks wrong. But instead of learning how to use tabs properly, they spit them out.
- pjmlp 5y agoIf one needs to be force fed to appreciate them, that already shows how much of a problem they are.
- globular-toast 5y agoChildren need to be forced to learn to read and write.
- pjmlp 5y agoSo using spaces is being illiterate.
- globular-toast 5y agoNot necessarily, but I am arguing that most people are tab illiterate. Things that are worth learning are rarely easy/obvious.
- m463 5y agoIf it were all tabs or all spaces, that could theoretically work. But in practice, any combination of tabs and spaces will look wrong for someone.
- Tade0 5y agoThe indentation I use cannot be expressed through tabs, unless they're of width 1, which defeats the purpose.
- AlexSW 5y agoI don't see why it defeats the purpose at all. You get to have your one-character-width indentation, while other devs will being able view it with more indentation width and spend less time dispairing at issues of readability for them. This seems like exactly what tabs are good for.
- Tade0 5y agoIf you're using indentation to e.g. align method parameters then no, tabs would just make a mess out of it.
- j1elo 5y agoThen you get someone who uses a tab size of 2 spaces and this allows them for a longer line than you with your 4 or 8 spaces-sized tab. And all alignments are wrong (you know, "indent with tabs, but align with spaces" but then people are not perfect and things end up mix-and-matched) because everything is calculated to fit _their_ tab size and nothing else. Besides, everything looks horribly indented when looking at the code in Github, which renders huge and ugly 8 spaced-tabs, so lines with just a couple tabs already tend to travel to the right and disappear when using a two-column display :-( This kind of things are what drove me from using tabs, to preferring and LOVING an already strongly opinionated tool like Prettier.js. Just apply the defaults, no more bikeshedding discussions.
- withinboredom 5y agoWe use tabs at work. I haven't ever had any alignment issues or nasty diffs. Some people work with "two spaces" and some people with "four spaces". The rules of alignment have to make sense, you don't just align wherever you want. There's a style guide of when to align and when not to align (but the IDE and tooling does it all for you) and it all comes out quite beautiful no matter how you have your tab chars to display.
- gsich 5y agoI don't care how it looks on other computers. This is a problem of the user of that other computer.
- brigandish 5y agoThere’s always the CSS tab-size property[1] if you don’t like the default width (and who would, it’s huge!) [1] https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size
- BelenusMordred 5y ago> everyone can use the indentation they prefer without causing conflicts It's one line in a githook for this to really be true.