Indentation (typesetting)

Look up indentation in Wiktionary, the free dictionary.

In the written form of many languages, an indentation 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 and unindent are used to describe the reversal of the indentation process, realigning text with the page margin (or with previous, lesser, levels of indentation).

In right-to-left languages (e.g. Hebrew and Arabic), identation 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.

A first-line indentation indents the first line.
A first-line indentation of 2 em:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 
A hanging indentation indents the rest of the text while leaving the first line in place.
A hanging indentation of 2 em:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
A block indentation indents the entire block of text.
A block indentation of 2 em on the left:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Indentation from both sides is commonly used for block quotations, here shown with 2 em on the left and right (which may amount to more on the right for certain lines, depending on word wrapping, if the text does not have justified alignment):
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
A justified-text example of a block quotation that has been block-indented from both sides by 3 em:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Indentation in programming

Main article: Indent style

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.[1] Different indentation styles are commonly used. In 2006 a third method of indentation was proposed, called elastic tabstops.

Language Indent Note
Bash varies Google uses 2 spaces.[2]
C varies The Linux kernel uses 8 spaces.[3] NASA uses 4 spaces.[4]
C++ varies Google uses 2 spaces.[5]
C# 4 spaces As per Microsoft's C# Coding Conventions.[6]
CSS varies Drupal, GitHub, and Google use 2 spaces.[7][8][9]
Go 1 tab As per "Effective Go".[10]
Haskell varies Google uses 2 spaces.[11]
HTML varies Google uses 2 spaces.[9] HTML Tidy defaults to 2 spaces.[12]
Java 4 spaces Oracle says four spaces.[13] Android uses four spaces.[14]
JavaScript varies Douglas Crockford advocates four spaces.[15] GitHub and Google uses 2 spaces.[16][17] jQuery uses tabs.[18] Firefox's built-in jsbeautifier defaults to 2 spaces. The built-in prettyprinter in Google Chrome and Internet Explorer uses 4 spaces.
Lua 2 spaces As per Lua Style Guide.[19]
Perl 4 spaces As per "perlstyle: Perl style guide".[20]
PHP varies Drupal use 2 spaces.[21] PEAR and Zend use 4 spaces.[22][23] CodeIgniter and WordPress uses tabs.[24][25] PSR-2 specifies 4 spaces.[26]
Python 4 spaces As per PEP-8.[27]
Ruby 2 spaces As per Ruby Style Guide.[28]
Rust 4 spaces As per Rust Style Guide.[29]
Scala 2 spaces As per Scala style guide.[30]
Tcl 4 spaces As per Tcl style guide.[31]
Visual Basic 4 spaces As per Microsoft's Visual Basic Coding Conventions.[32]

References

  1. "Tabs versus Spaces: An Eternal Holy War". Jwz.org. 2007-01-05. Retrieved 2014-01-18.
  2. https://google-styleguide.googlecode.com/svn/trunk/shell.xml
  3. https://www.kernel.org/doc/Documentation/CodingStyle
  4. http://homepages.inf.ed.ac.uk/dts/pm/Papers/nasa-c-style.pdf
  5. http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Spaces_vs._Tabs
  6. http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
  7. "CSS formatting guidelines". Drupal.org. Retrieved 2014-01-18.
  8. "CSS · Styleguide · GitHub". Github.com. Retrieved 2014-01-18.
  9. 1 2 "Google HTML/CSS Style Guide". Google GitHub. Google. Indentation. Retrieved 2016-03-13. Indent by 2 spaces at a time. This is an HTML-rendered copy of the official version, which is maintained in XML format, at https://github.com/google/styleguide/blob/gh-pages/htmlcssguide.xml (version 2.2.3, 2013-07-23).
  10. http://golang.org/doc/effective_go.html
  11. "HaskellStyleGuide - ganeti - Style Guide for the Haskell code - Cluster-based virtualization management software - Google Project Hosting". Code.google.com. 2014-01-08. Archived from the original on June 27, 2013. Retrieved 2014-01-18.
  12. "HTML Tidy Configuration Options Quick Reference". Tidy.sourceforge.net. 2008-06-18. Retrieved 2014-01-18.
  13. "Code Conventions for the Java Programming Language: 4. Indentation". Oracle.com. Retrieved 2014-01-18.
  14. "Code Style Guidelines for Contributors | Android Developers". Source.android.com. Retrieved 2014-01-18.
  15. "Code Conventions for the JavaScript Programming Language". Javascript.crockford.com. 2006-11-13. Retrieved 2014-01-18.
  16. "JavaScript 路 Styleguide 路 GitHub". Github.com. Retrieved 2014-01-18.
  17. "JaveScript Style Rules". Google-styleguide.googlecode.com. Retrieved 2014-02-18.
  18. jQuery Foundation - jquery.org. "JavaScript Style Guide | Contribute to jQuery". Contribute.jquery.org. Retrieved 2014-01-18.
  19. http://lua-users.org/wiki/LuaStyleGuide
  20. Perl5-porters group (2015-06-15). Allen, Jon (JJ), ed. "perlstyle: Perl style guide". Perl 5 Version 22.0 Documentation. Perl Foundation. Retrieved 2016-03-13.
  21. "Coding standards". Drupal.org. Retrieved 2014-01-18.
  22. "Manual :: Indenting and Line Length". Pear.php.net. Retrieved 2014-01-18.
  23. "PHP Coding Standard (draft) - Contributors - Zend Framework Wiki". Framework.zend.com. Retrieved 2014-01-18.
  24. "Style Guide : CodeIgniter User Guide". Ellislab.com. Retrieved 2014-01-18.
  25. "WordPress › PHP Coding Standards « Make WordPress Core". Make.wordpress.org. Retrieved 2014-01-18.
  26. "PHP : Coding Style Guide". Php-fig.org. Retrieved 2014-02-18.
  27. https://www.python.org/dev/peps/pep-0008/#indentation
  28. https://github.com/bbatsov/ruby-style-guide#source-code-layout
  29. https://github.com/rust-lang/rust/wiki/Note-style-guide
  30. http://docs.scala-lang.org/style/indentation.html
  31. http://www.tcl.tk/doc/styleGuide.pdf
  32. http://msdn.microsoft.com/en-us/library/aa733583%28v=vs.60%29.aspx
Wikimedia Commons has media related to Indentation (typesetting).
This article is issued from Wikipedia - version of the 11/16/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.