Tabs versus spaces, thoroughly #align Tabs for indentation, spaces for alignment People keep spamming this as if it means anything. Tabs for alignment is not a thing. We're not going back to that. Throughout this file, monosyllabic ''tabs'' is shorthand for tabs for indentation and spaces for alignment. Oh, and about this: function-function1(-argument1, =======>------------argument2, =======>------------argument3)-{ =======>statement1; } Yes, mixing tabs and spaces like this is cursed, but this kind of alignment is cursed regardless of how it's achieved. Exception: lisps, see #safe #ast Editing abstract syntax trees directly would free us to transend the cursed textual plane Nah, like plain text. Always bet on text https://graydon.livejournal.com/196162.html https://graydon2.dreamwidth.org/193447.html #auto Just automate it This solves the problem, but it doesn't answer the question. Also, code style should be simple enough that a developer can just type correctly formatted code. #custom Consistency versus customizability Iñaki Baz Castillo wrote https://twitter.com/ibc_tw/status/776052508007555076 To be clear: all those using spaces instead of tabs for indentation are irredeemably wrong. Let me see your code in the way I like. Period. Drew DeVault wrote https://cmpwn.com/@sir/104615166548400832 @neauoire the other reason which should immediately shut down the discussion is that tabs are more accessible. If you have a vision impairment then tabs allow you to customize the display of the code to read more comfortably. This argument is best made in this reddit post https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/ A Hacker News user with a throwaway account wrote this about it https://news.ycombinator.com/item?id=20341654 Not going to get into the details of the argument (there is a reason tabs vs spaces is considered the prototypical "religious war"), but I do strongly disagree with the way it was argued, and I felt the need to comment because I so frequently see this type of discourse and find it very disheartening. It's what I usually call the "If you disagree with me you want to kill puppies" (or, in this case, "if you disagree with me you hate blind people") form of argument. The author really isn't inviting people to challenge his thinking with his final sentence - I feel like he's instead trying to flat out invalidate other opinions by emphasizing how callous you must be to have them. #elastic Elastic tabstops Great idea, sadly seems kind of unworkable. EDIT: I've changed my mind on this. TODO: update. #filesize Tabs make for smaller files The many more meaningful arguments from both sides make this irrelevant to me. At worst, people merely type it to grow their pros&cons lists. At best, people use it as evidence of the superiority of tabs, not so much as a reason to choose them. #invisible Invisible characters are special https://twitter.com/sysarmy/status/1214517062749609989 https://twitter.com/eevee/status/1258176886422691841 "here is how to correctly mix these invisible characters, a thing space people literally never have to try to do, it's in the name" https://twitter.com/eevee/status/1258180312422440960 look it's not hard. tabs for indentation, spaces for alignment, form feeds between function arguments, soft hyphens between array elements, paragraph separators between methods. i love to encode metadata with invisible characters instead of doing programming https://www.youtube.com/watch?v=En8Ubs2k1O8 It's not about which one is better. It's about which one can we get rid of. And we can't get rid of spaces. #monospace Matters of typography TODO: set virtualedit=all On font fallbacks and failures https://macwright.com/2017/11/18/typography-thoughts.html TODO: rewrite. #portable Tabs aren't portable I've heard places that tabs aren't supported everywhere. TODO: fact check. #prefix Prefixability Lots of pieces of notation consist of inserting characters at the start of a line like #s for comments, >s for quotes, +s for diffs and so on. When done to text indented with spaces, the text is reproduced verbatim a couple of columns to the left. In the case of tabs, there are lots of edge cases that can make the text look wrong, and doubly so when you use custom tabstop values such as 4: function-f(x)-{ ===>return-true; } //-function-f(x)-{ //->return-x; //-} Yeah, not good. This would not be the case if the convention were prefix-tab instead of prefix-space, but that would shift things too much to the left for default values of 8 column tabstops. Also, good luck getting THAT to catch on. #safe Freedom versus safety Spaces allow for wrong indentation, where bad indentation means mistakenly putting N±1 space indents in an N space codebase, or something of the sort. You get the idea. Wrong indentation is still possible with tabs --if a space slips through-- but likely way less common. Counterpoint: freedom over safety. TODO. #salary People who indent with [TODO: which one?] make more money Abuse of statistics and tired, forced meme. #semantic Tabs mean indentation TODO wrote https://web.archive.org/web/20131209200846/http://derkarl.org/why_to_tabs.html Tabs are meant to indent, that's exactly what they do, that's only what they do. They're not meant to format text, to align it in columns, to put your comments into a regular block. Xah Lee wrote http://xahlee.info/UnixResource_dir/writ/tabs_vs_spaces.html the semantics of tab is what indenting is about, while, using spaces to align code is a hack. https://twitter.com/nikitonsky/status/497668345723101187 Tabs were invented for tabular data. Source code is not tabular, so check and mate, go indent with spaces. https://twitter.com/sebmck/status/1261831532496384001 Honestly if you find the accessibility argument weak, and many do, consider that the tab character is literally for indentation. Gary Bernhardt @garybernhardt wrote https://twitter.com/garybernhardt/status/218026131725623296 > "The accidental lingering aftereffects of typewriters' mechanical > limitations are integral to the experience of programming." > > — Tabs. TODO: Who is correct here? Was the tab key invented before the invention of indenting code? #support Every editor supports tabs Indenting with spaces is not supported in every environment, to my knowledge there's no way to get an interactive shell to interpret the tab key as a number of spaces. Ditto some old but important text editors like the original vi. If you use tabs you need to set up your text editor to know how many spaces an indent level is and insert, delete and move that many spaces when you're at the start of a line. (And possibly more things.) If you use tabs you need none of that, it solves all of it for you. You should set it up to let you know if you mix spaces and tabs but space people should do that too, they just don't need it as bad. *** #any Always do this regardless of preference Get your setup to spot mixed up invisible characters for you. Relevant git config settings: [apply] whitespace = fix [core] whitespace = space-before-tab,trailing-space #spaces Break glass in case of spaces How many? To me, 2 spaces is indisputably nowhere near enough indent to easily scan the structure of code. 4 is workable, but still not ideal. 8 happens to be the sweet spot. Regardless, make it easy for developers to comply with your projects tab length. Editorconfig is overkill but worth it. EditorConfig https://editorconfig.org/ #tabs Break glass in case of tabs TODO *** Adam Spiers https://adamspiers.org/computing/why_no_tabs.html Bart Groeneveld https://gitlab.com/BartG95/dot/-/blob/c79d086a6b43dde214efb8352ac20390bce65a0b/editorconfig/.editorconfig#L99 derkarl.org https://web.archive.org/web/20131209200846/http://derkarl.org/why_to_tabs.html Jamie Zawinsky https://www.jwz.org/doc/tabs-vs-spaces.html Lea Verou https://lea.verou.me/tag/coding-standards/ Stackexchange thread https://softwareengineering.stackexchange.com/questions/57/tabs-versus-spaces-what-is-the-proper-indentation-character-for-everything-in-e