The Bible of Tabs vs Spaces Holy War

[Tabs vs Spaces War (Silicon Valley)]
The following list of references is obviously not exhaustive, but there has no cherry picking.
If you have some other references or programming languages to add, please email me to olivier.pirson.opi@gmail.com .
Spaces win. 🏆 Tabs are tolerated in Makefile and TSV files. 😂

Ada

Use spaces for indentation, not the tab character (Nissen and Wallis 1984, [Portability and style in Ada,] w2.2). (Ada ’83 Quality and Style: Guidelines for Professional Programmers / 2 Source Code Presentation / 2.1 code formatting)

Indenting with spaces is more portable than indenting with tabs because tab characters are displayed differently by different terminals and printers.
exceptions
If you are using a variable width font, tabs will align better than spaces. However, depending on your tab setting, lines of successive indentation may leave you with a very short line length.
(Ada Style Guide/Source Code Presentation / Indentation, Wikipedia)

assembly

I recommend that you indent code (or use horizontal space) in some sensible fashion (but avoid tabs, use spaces) (Assembly Language Coding Standards / Assembly language coding / Formatting, Ken Clowes, 2000)

Avoid Tab Characters
Always use multiple space characters rather than tab characters in code files. […]
(A Coding Standard for HCS08 Assembly Language, p.3, Freescale Semiconductor, 2004)

Assembly files must be formatted with all directives indented two spaces, except for labels. (RISC-V Assembly Style Guide / .S Files / Indentation, OpenTitan)

TAB characters must be expanded to spaces. (C and Assembly sources style guide / All Sources, cc65)

Bash

Indent 2 spaces. No tabs. (Google Shell Style Guide / Indentation)

Don’t use (smart-)tabs. Replace a tab by two spaces. (bash-coding-style / Naming and styles / Tabs and Spaces)

BASIC

Insert tabs as spaces, and use smart indenting with four-space indents. (Visual Basic Coding Conventions / Layout Conventions)

C

Indentation
In general there are two preferred indentation styles for code in GNOME.
1. Linux Kernel style. Tabs with a length of 8 characters are used for the indentation, with K&R brace placement:
[…]
2. GNU style. Each new level is indented by 2 spaces, braces go on a line by themselves, and they are indented as well.
[…]
Tab Characters
Do not ever change the size of tabs in your editor; leave them as 8 spaces. Changing the size of tabs means that code that you didn’t write yourself will be perpetually misaligned.
(C Coding Style, GNOME)

Tabs are 8 characters, and thus indentations are also 8 characters. (Linux kernel coding style v5.5 / Indentation)

Tabs are 8 characters. They are NOT adjustable. Never have been, never will be. Anybody who thinks tabs are anything but 8 chars apart is just wrong. It’s that simple. (Linus Torvalds, 19 January 2001)

Indent your code four spaces at a time to make clear which blocks of code are inside of others. If you use your keyboard’s Tab key to do so, be sure that your text editor’s configured to convert tabs (\t) to four spaces, else your code may not print or display properly on someone else’s computer, since \t renders differently in different editors. (Style Guide for C / Indentation, Harvard CS50x)

TAB characters must be expanded to spaces. (C and Assembly sources style guide / All Sources, cc65)

4 spaces per indentation level, no tabs (Notes for Julia Contributors / Submitting contributions / Code Formatting Guidelines / General Formatting Guidelines For C code contributions, Julia)

C++

Never Mix Tabs and Spaces
Some editors like to indent with a mixture of tabs and spaces by default. This makes the code unreadable to anyone not using the exact same tab indentation settings. Configure your editor so this does not happen.
(C++ Best Practices / Never Mix Tabs and Spaces)

Use only spaces, and indent 2 spaces at a time.
We use spaces for indentation. Do not use tabs in your code. You should set your editor to emit spaces when you hit the tab key.
(Google C++ Style Guide / Spaces vs. Tabs)

Use only spaces, and indent 2 spaces at a time. We use spaces for indentation. Absolutely do not use tabs in your code. (C++ style guide / Formatting / Indentation, GNU Octave)

Do not use tabs. Use spaces, as tabs are defined differently for different editors and printers. (C++ Coding Standards and Style Guide / 3 Formatting / 3.5 Tab / Space, p.11, NASA, 2005)

C#

Use the default Code Editor settings (smart indenting, four-character indents, tabs saved as spaces). (C# Coding Conventions (C# Programming Guide) / Layout Conventions)

Clojure

Use spaces for indentation. No hard tabs. (The Clojure Style Guide / Tabs vs Spaces)

CoffeeScript

Use spaces only, with 2 spaces per indentation level. Never mix tabs and spaces. (CoffeeScript Style Guide / Code Layout / Tabs or Spaces?, Polar)

CSS

Indent by 2 spaces at a time.
Don’t use tabs or mix tabs and spaces for indentation.
(Google HTML/CSS Style Guide / Indentation)

Use tabs, not spaces, to indent each property. (WordPress CSS Coding Standards / Structure)

D

Use spaces instead of hardware tabs. (The D Style / Whitespace)

Dart

DON’T use tabs.
Using spaces for formatting ensures the code looks the same in everyone’s editor. It also makes sure it looks the same when posted to blogs, or on code sites like Google Code or GitHub.
(Dart Style Guide / Whitespace, Bob Nystrom)

Eiffel

The comb structure uses indentation, achieved through tab characters (not spaces, which are messy, error-prone, and not reader-parameterizable). (Style Guidelines / TEXT LAYOUT AND PRESENTATION / Indenting details)

Erlang

Use 2 space indent, no tabs. (Erlang Coding Style Guide / Practice / File Composition)

Spaces over tabs, 2 space indentation. (Inaka’s Erlang Coding Guidelines / Conventions & Rules / Source Code Layout / Spaces over tabs)

F#

Using spaces
When indentation is required, you must use spaces, not tabs.
(F# code formatting guidelines / General rules for indentation)

Fortran

Use 4 spaces indentation (this is again a matter of preference as some people prefer 2 or 3 spaces). (Fortran Best Practices / Fortran Style Guide / Indentation, Fortran 90)

18. Do not use “hard” tabs.
Tabulation characters, “tabs,” can be a convenient way to insert multiple columns of white space into source code with a single keystroke. However, the use of tabs is not specified by the Fortran standard. Different environments and editors display and compile tab characters in different manners. Code that appears well laid out in one editor may appear skewed in a second. Some compilers may treat a tab as a single character, while others might treat it as representing multiple blank characters. This is a problem when calculating line length limits and when tabs appear in character literals. Use spaces instead of tabs or set the editor to replace tabs with an equivalent number of spaces when the tab key is pressed.
(Modern Fortran: Style and Usage / 3. Formatting Conventions / 3.4 White Space, p.20, Norman S. Clerman and Walter Spector, 2012)

[spaces] Please, avoid hard tabs. (ZEN of Fortran / Readability / White spaces)

GNU Octave

and

MATLAB

Use only spaces, and indent 2 spaces at a time.
We use spaces for indentation. Absolutely do not use tabs in your code.
(Octave style guide / Formatting / Indentation)

[spaces] 10. Do Not Use Hard Tabs (The Elements of MATLAB Style / 2. Formatting / Layout, p.9, Richard K. Johnson, 2011)

Go (Golang)

We use tabs for indentation and gofmt emits them by default. Use spaces only if you must. (Effective Go / Formatting)

Haskell

Tabs are illegal. Use spaces for indenting. Indent your code blocks with 4 spaces. (Haskell Style Guide / Indentation)

HTML

Indent by 2 spaces at a time.
Don’t use tabs or mix tabs and spaces for indentation.
(Google HTML/CSS Style Guide / Indentation)

Use tabs and not spaces. (WordPress HTML Coding Standards / Indentation)

Java

◦ 4-space indents.
Spaces, not tabs.
(Java Coding style, Mozilla)

We use four (4) space indents for blocks and never tabs. When in doubt, be consistent with the surrounding code.
We use eight (8) space indents for line wraps, including function calls and assignments.
(AOSP Java Code Style for Contributors / Java style rules / Use spaces for indentation, Android Open Source Project)

Aside from the line terminator sequence, the ASCII horizontal space character (0x20) is the only whitespace character that appears anywhere in a source file. This implies that:
1. All other whitespace characters in string and character literals are escaped.
2. Tab characters are not used for indentation.
(Google Java Style Guide / Whitespace characters)

[spaces] No tabs
An oldie, but goodie. We’ve found tab characters to cause more harm than good.
(Java Style Guide / Coding style / Formatting, Twitter)

Indentation is using spaces - never tabs. (The Official raywenderlich.com Java Style Guide / Spacing / Indentation)

• Two spaces should be used as the unit of indentation;
• Tabs must expand to spaces and the tab width should be set to two
(Code Style Guide / Guideline / 3. Indentation, Gobblin)

Four spaces should be used as the unit of indentation. The exact construction of the indentation (spaces vs. tabs) is unspecified. Tabs must be set exactly every 8 spaces (not 4). (Code Conventions for the Java Programming Language / 4 - Indentation, Sun, 1999)

JavaScript

Four spaces (no tabs). (Coding style / Indentation, W3C)

So, I propose that from this point on, no more tabs. Don’t misunderstand this. The argument is not which way is better. The argument is: which one can we get rid of? We can’t get rid of space, so the one that has to go is tab. (46′39, start to 5′53) (The Post JavaScript Apocalypse, Douglas Crockford, 8 March 2017)

Use of tabs invites confusion, argument, and crying, with little compensating value. Do not use tabs. Use space. (Code Conventions for the JavaScript Programming Language / Whitespace, Douglas Crockford, 2019)

Tabs and spaces should not be mixed. We should pick just one in order to avoid the problems that come from having both. Personal preference is an extremely unreliable criterion. Neither offers a powerful advantage over the other. Fifty years ago, tab had the advantage of consuming less memory, but Moore’s Law has eliminated that advantage. Space has one clear advantage over tab: there is no reliable standard for how many spaces a tab represents, but it is universally accepted that a space occupies a space. So use spaces. You can edit with tabs if you must, but make sure it is spaces again before you commit. Maybe someday we will finally get a universal standard for tabs, but until that day comes, the better choice is spaces. (JSLint: Help / Whitespace, Douglas Crockford)

Use 2 spaces for indentation. (JavaScript Standard Style / Rules)

Aside from the line terminator sequence, the ASCII horizontal space character (0x20) is the only whitespace character that appears anywhere in a source file. This implies that
1. All other whitespace characters in string literals are escaped, and
2. Tab characters are not used for indentation.
(Google JavaScript Style Guide / 2 Source file basics / 2.3 Special characters / 2.3.1 Whitespace characters)

I like to use two spaces for every open block, but tastes differ—some people use four spaces, and some people use tab characters. The important thing is that each new block adds the same amount of space. (Eloquent JavaScript / 2. Program Structure / Indenting Code)

Indentation with tabs. (WordPress JavaScript Coding Standards / Spacing)

Julia

Indent within new blocks (except module) using 4 spaces (Style guide and design principles / Style guide / Formatting / Whitespace)

Use 4 spaces per indentation level, no tabs. (Blue: a Style Guide for Julia / Synopsis, Invenia Technical Computing)

4 spaces per indentation level, no tabs (Notes for Julia Contributors / Submitting contributions / Code Formatting Guidelines / General Formatting Guidelines for Julia code contributions)

Use 4 spaces for indentation; no tabs, ever. (YASGuide – Yet Another Style Guide For Julia / Line/Alignment/Spacing Guidelines)

Kotlin

Use 4 spaces for indentation. Do not use tabs. (Coding Conventions / Formatting)

Aside from the line terminator sequence, the ASCII horizontal space character (0x20) is the only whitespace character that appears anywhere in a source file. This implies that:
• All other whitespace characters in string and character literals are escaped.
• Tab characters are not used for indentation.
(Kotlin style guide / Source files / Special Characters / Whitespace characters, Android)

Indentation is using spaces - never tabs. (The raywenderlich.com Kotlin style guide / Spacing / Indentation)

Lisp

Horizontal white space: none around parentheses. No tabs. (Google Common Lisp Style Guide / Formatting / Horizontal white space)

Use spaces for indentation. No hard tabs. (The Emacs Lisp Style Guide / Source Code Layout & Organization)

ML

and

OCaml

No Tab Characters. Do not use the tab character (0x09). Instead, use spaces to control indenting. The Emacs package from this website avoids using tabs (with the exception of pasting text from the clipboard or kill ring). This is because the width of a tab is not uniform across all computers, and what looks good on your machine may look terrible on mine, especially if you have mixed spaces and tabs. (CS312 SML Style Guide / File Submission, Cornell CIS, 2008)

Indent with space characters, not tab characters, so that your white space is always rendered as you intended. (SML Style Guide / 2 Rules / 2.1 Write code to be read / 2.1.4 Emphasize structure with white space, p.3, Carnegie Mellon, School of Computer Science, 2012)

Code may not contain tab characters. The width of a tab character varies with the machine, and what looks good on your machine may look terrible on mine. For indentation, use spaces. (Style guide for Standard ML programmers / 2 Basic courtesy, p.2, COMP 105, Tufts Computer Science, 2020)

The change in indentation between successive lines of the program is generally 1 or 2 spaces. Pick an amount to indent and stick with it throughout the program.
Using tab stops
Using the tab character (ASCII character 9) is absolutely not recommended.
Justification: Between one display and another, the indentation of the program changes completely; it can also become completely wrong, if the programmer used both tabulations and spaces to indent the program.
Criticism: The purpose of using tabulations is just to allow the readers of the program to indent more or less by changing the tabs stops. The overall indentation remains correct and the reader is glad to easily customize the indentation amount.
Answer: It seems almost impossible to use this method since you should always use tabulations to indent, which is hard and unnatural.
(OCaml Programming Guidelines / Indentation of programs / How much to indent)

No Tab Characters. Do not use the tab character (0x09). Instead, use spaces to control indenting; we generally recommend 2 spaces per indent, but 4 is also fine. The width of a tab is not uniform across all editors, and what looks good on your machine might be unreadable on a grader’s, especially if there are mixed spaces and tabs. (CS 3110 OCaml Style Guide / File Format, Cornell CIS, 2017)

No Tab Characters: Do not use the tab character (0x09). Instead, use spaces to control indenting. (OCaml Style Guide / File Submission Requirements, Penn Engineering)

Nim

Two spaces should be used for indentation of blocks; tabstops are not allowed (the compiler enforces this). Using spaces means that the appearance of code is more consistent across editors. Unlike spaces, tabstop width varies across editors, and not all editors provide means of changing this width. (Nim Enhancement Proposal #1 – Standard Library Style Guide / Spacing and Whitespace Conventions)

Objective-C

Use only spaces, and indent 2 spaces at a time. We use spaces for indentation. Do not use tabs in your code. (Google Objective-C Style Guide / Spacing and Formatting / Spaces vs. Tabs)

Indent using 2 spaces (this conserves space in print and makes line wrapping less likely). Never indent with tabs. (The official raywenderlich.com Objective-C style guide / Spacing)

Oz

Tabs are prohibited anywhere. Use only spaces. (Coding Style Guidelines / Blanks, mozart-oz)

Pascal

Do not use TAB characters (ASCII HT, 0x09). There is no standard default TAB setting, so the look of source files using TAB characters will depend on client settings. This may result in a chaotic view of source files. Align by space characters (also see Indentation). (Coding style / TAB characters, Free Pascal)

You should always indent two spaces for all indentation levels. In other words, the first level of indentation is two spaces, the second level four spaces, the third level 6 spaces, etc. Never use tab characters. (Object Pascal Style Guide / 4 White Space Usage / 4.3 Indentation, Delphi)

Perl

and

Raku

(Perl 6)

Indent with spaces, not tabs. Tabs are a bad choice for indenting code, even if you set your editor’s tabspacing to four columns. Tabs do not appear the same when printed on different output devices, or pasted into a word-processor document, or even just viewed in someone else’s differently tabspaced editor. So don’t use tabs alone or (worse still) intermix tabs with spaces: […]
The only reliable, repeatable, transportable way to ensure that indentation remains consistent across viewing environments is to indent your code using only spaces. And, in keeping with the previous rule on indentation depth, that means using four space characters per indentation level: […]
Note that this rule doesn’t mean you can’t use the Tab key to indent your code; only that the result of pressing that key can’t actually be a tab. […]
Ideally, your code should not contain a single instance of the tab character. In your layout, they should have been transformed to spaces; in your literal strings, they should all be specified using \t
(Perl Best Practices / Code Layout / Tabs, p.20, Damian Conway, 2005)

Use always space, never tabs. (Style guide / Text, Raku)

PHP

Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting. (PSR-2: Coding Style Guide / 2. General / 2.4. Indenting, PHP-FIG)

Code MUST use an indent of 4 spaces for each indent level, and MUST NOT use tabs for indenting. (PSR-12: Extended Coding Style / 2. General / 2.4 Indenting, PHP-FIG)

Use an indent of 4 spaces, with no tabs. This helps to avoid problems with diffs, patches, SVN history and annotations. (Coding Standards / Indenting and Line Length, PEAR)

Use real tabs and not spaces, as this allows the most flexibility across clients. (WordPress PHP Coding Standards / Indentation)

PostScript

Indent 2 spaces per indentation level. You may use tabs at the left margin for indentation, with 1 tab = 8 spaces, but you should not use tabs anywhere else, except to place comments. (Ghostscript PostScript Coding Guidelines / 7. Formatting / 7.1 Indentation)

Processing

Always spaces, two of them. Never tabs. (Style Guidelines / Indentation)

Prolog

2.1 Indent with spaces instead of tabs
You cannot normally predict how tabs will be set in the editors and browsers that others will use on your code. Moreover, mixing tabs and spaces makes searches and substitutions more problematic. All in all, it is better not to use tabs altogether: Almost any editor can be set to substitute spaces for tabs automatically when saving your file.
(Coding Guidelines for Prolog / 2. Layout, p.892, Michael A. Covington Roberto Bagnara Richard A. O’keefe Jan Wielemaker Simon Price, 30 June 2011)

The change in indentation between successive blocks of the program is of 3 spaces. Both spaces and tab stops (ASCII character 9) have advantages, however hard spaces have been chosen (for instance to ease inclusion of source files into LaTeX or HTML documents). If necessary use your editor to transform tabs into spaces. (Prolog programming guidelines / Indentation of programs / How much to indent, Inria)

Indent your source file using tabs, not spaces. Never mix tabs and spaces for indentation. But do use spaces for alignment that is not related to indenting. One tab is one level of indentation and is independent of each team member preferred setting. A common setting is a tab width equivalent to four spaces. Check that when changing the tab width that your code and comments remain perfectly indented. Use one tab for indenting the code encapsulated inside an entity. Indent the body of predicate clauses using one tab. (Coding Style Guidelines / Source code layout and indentation, Logtalk)

Python

Spaces are the preferred indentation method.
Tabs should be used solely to remain consistent with code that is already indented with tabs.
Python 3 disallows mixing the use of tabs and spaces for indentation.
Python 2 code indented with a mixture of tabs and spaces should be converted to using spaces exclusively.
(PEP8 – Style Guide for Python Code / Tabs or Spaces?)

Indent your code blocks with 4 spaces. (Google Python Style Guide / Python Style Rules / Indentation)

R

The contents should be indented by two spaces. (The tidyverse style guide / 2 Syntax / 2.4 Control flow / 2.4.1 Code blocks)

Ruby

Use only spaces for indentation. No hard tabs. (The Ruby Style Guide / Source Code Layout / Tabs or Spaces?)

[spaces] Use soft-tabs with a two-space indent. (Ruby Style Guide / Whitespace / Indentation, Airbnb)

Rust

Use 4 spaces for indentation, not tabs. (Rust Style Guidelines / Whitespace)

Use spaces, not tabs. (Rust Style Guide / Formatting conventions / Indentation and line width, Rust code formatting RFCs)

Scala

Each level of indentation is 2 spaces. Tabs are not used. (Scala Style Guide / Indentation)

[spaces] Use 2-space indentation in general. (Databricks Scala Guide / Syntactic Style / Spacing and Indentation)

Scheme

and

Racket

[spaces] Do not use tab characters in your code. Tabs make it hard to use textual tools like git or diff effectively. (How to Program Racket: a Style Guide / 6 Textual Matters / 6.3 Tabs)

Indentation should be consistantly 2 or 3 spaces (not tab characters). (CS 115, CS 116, CS 135, & CS 136 Style Guide / 8 Changes for C (CS 136) / 8.4 Indentation and Whitespace, p.37, The University of Waterloo, 2019)

Smalltalk and Pharo

5.7 Guideline: Use tabs not spaces to indent and use spaces to help reading
When navigating from one element to the next one, spaces and tabs are the same. Since they do not have a visual representation the reader cannot know in advance if the white space in front of word is a tab or multiple spaces. It is then annoying to handle spaces manually.
• Avoid extra spaces at the beginning and use tabs to indent.
(Pharo with Style / 5. About code formatting, p.32, Stéphane Ducasse)

SQL

[spaces] Spaces should be used to line up the code so that the root keywords all end on the same character boundary. This forms a river down the middle making it easy for the readers eye to scan over the code and separate the keywords from the implementation detail. Rivers are bad in typography, but helpful here. (SQL Style Guide / White space / Spaces)

No tabs should be used - only spaces. (SQL Style Guide / General, GitLab)

No tabs. 2 spaces per indent. (Kickstarter SQL Style Guide / Rules / General stuff)

No tabs. Use spaces for indents. (Modern SQL Style Guide / Rules / Whitespace)

SVG

Two spaces indenting (SVG Guidelines / Authoring guidelines / Basics, Mozilla)

Swift

Aside from the line terminator, the Unicode horizontal space character (U+0020) is the only whitespace character that appears anywhere in a source file. The implications are:
• All other whitespace characters in string and character literals are represented by their corresponding escape sequence.
• Tab characters are not used for indentation.
(Swift Style Guide / Source File Basics / Whitespace Characters, Google)

Indent using 2 spaces rather than tabs to conserve space and help prevent line wrapping. (The official Swift style guide for raywenderlich.com / Spacing)

Tcl/Tk

Each level of indentation should be four spaces. There are ways to set 4-space indents in all of the most common editors. Be sure that your editor really uses four spaces for the indent, rather than just displaying tabs as four spaces wide; if you use the latter approach then the indents will appear eight spaces wide in other editors. (Tcl Style Guide / 6. Low-level coding conventions / 6.1 Indents are 4 spaces, Ray Johnson)

TypeScript

Use 2 spaces. Not tabs.
Reason: More JavaScript teams do this (e.g. airbnb, idiomatic, standard, npm, node, google/angular, facebook/react). The TypeScript/VSCode teams use 4 spaces but are definitely the exception in the ecosystem.
(TypeScript StyleGuide and Coding Conventions / Spaces)

VHDL

The TAB character shall not be used to indent, only use the space character. (VHDL Style Guide / Positioning, v.1.0, 2008)

whitespace

The only lexical tokens in the whitespace language are Space (ASCII 32), Tab (ASCII 9) and Line Feed (ASCII 10). By only allowing line feed as a token, CR/LF problems are avoided across DOS/Unix file conversions. (Um, not sure. Maybe we’ll sort this in a later version.). (whitespace tutorial)

Thus, programs must be written for people to read, and only incidentally for machines to execute.
(Structure and Interpretation of Computer Programs, Harold Abelson and Gerald Jay Sussman)

On the subject of C program indentation:
In My Egotistical Opinion, most people’s C programs should be indented six feet downward and covered with dirt.
😂
(Blair P. Houghton)