Indentation (typesetting)


In the written form of many languages, an indentation or indent is an empty space at the beginning of a line to signal the start of a new paragraph. Many computer languages have adopted this technique to designate "paragraphs" or other logical blocks in the program.
For example, the following lines are indented, using between one and six spaces:
This paragraph is indented by 1 space.
This paragraph is indented by 3 spaces.
This paragraph is indented by 6 spaces.
In computer programming, the neologisms outdent, unindent and dedent are used to describe the reversal of the indentation process, realigning text with the page margin.
In right-to-left languages, indentation is used just the same, but from the right margin of the paper, where the line begins.

Indentation in typesetting

There are three main types of indentation, illustrated below in relation to borders representing the page dimensions.

Indentation in programming

In computer programming languages, indentation is used to format program source code to improve readability. Indentation is generally only of use to programmers; compilers and interpreters rarely care how much whitespace is present in between programming statements. However, certain programming languages rely on the use of indentation to demarcate programming structure, often using a variation of the off-side rule. The Haskell, Occam, Python, and Ya programming languages rely on indentation in this way.
Debates over where to indent, whether to use spaces or tabs, and how many spaces to use are often hotly debated among programmers, leading some to classify indentation as akin to a religious war. In 2006 a third method of indentation was proposed, called elastic tabstops.
In addition to general indentation of statements, different bracket indentation styles are commonly used.
LanguageIndentNote
BashvariesFritz Mehner's Style Guide suggests 2, 4, or 8 spaces and uses 2 in all examples. Google uses 2 spaces.
CvariesThe Linux kernel uses 1 tab. NASA uses 4 spaces.
C++variesGoogle uses 2 spaces.
C#4 spacesPer Microsoft's C# Coding Conventions.
CSSvariesDrupal, GitHub, and Google use 2 spaces. WordPress uses tabs.
Delphi2 spacesDefault in RAD Studio.
Go1 tabPer "Effective Go".
HaskellvariesGoogle uses 2 spaces.
HTMLvariesGoogle uses 2 spaces. HTML Tidy defaults to 2 spaces.
JavavariesOracle uses 4 spaces. Android uses 4 spaces. Most Eclipse IDE components use tabs.
JavaScriptvariesDouglas Crockford advocates 4 spaces. GitHub and Google uses 2 spaces. jQuery uses tabs. Firefox's built-in jsbeautifier defaults to 2 spaces. The built-in prettyprinter in Google Chrome and Internet Explorer uses 4 spaces.
Kotlin4 spacesPer Kotlin style guide.
Lua2 spacesPer Lua Style Guide.
Perl4 spacesPer "perlstyle: Perl style guide".
PHPvariesDrupal use 2 spaces. PEAR and Zend use 4 spaces. CodeIgniter and WordPress uses tabs. PSR-2 specifies 4 spaces.
Python4 spacesPer PEP-8.
Ruby2 spacesPer Ruby Style Guide.
Rust4 spacesPer Rust Style Guide.
Scala2 spacesPer Scala style guide.
Tcl4 spacesPer Tcl style guide.
Visual Basic4 spacesPer Microsoft's Visual Basic Coding Conventions.