Indentation (typesetting)

From Wikipedia, the free encyclopedia
  (Redirected from Outdent)
Jump to: navigation, search

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 eight spaces:

 This paragraph is indented by 1 space.

  This paragraph is indented by 2 spaces.

    This paragraph is indented by 4 spaces.

      This paragraph is indented by 8 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.

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[edit]

There are two main types of first-line indent: normal and hanging. A "normal" indent indents the first line, as shown here, an indent of one centimeter:

Lorem ipsum dolor sit amet, consectetur adipisicing 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.

The other kind, a hanging indent, indents the rest of the text while leaving the first line in place; as shown here with a hanging indent of one centimeter:

Lorem ipsum dolor sit amet, consectetur adipisicing 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[edit]

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 Google uses 2 spaces.[3]
C# 4 As per Microsoft's C# Coding Conventions
CSS Varies Google, GitHub and Drupal uses 2 spaces.[4][5][6]
Go Tabs As per http://golang.org/doc/effective_go.html
Haskell  ? Google uses 2 spaces.[7]
HTML Varies Google uses 2 spaces.[4] HTML Tidy defaults to 2 spaces.[8]
Java 4 Oracle says four spaces.[9] Android uses four spaces.[10]
JavaScript Varies Douglas Crockford advocates four spaces.[11] Google and GitHub uses two spaces.[12][13] jQuery uses tabs.[14] Firefox built-in jsbeautifier defaults to two spaces. The built-in prettyprinter in Chrome and Internet Explorer uses four spaces.
Lua 2 http://lua-users.org/wiki/LuaStyleGuide
Perl 4 As per Perl style guide
PHP Varies Drupal use 2 spaces.[15] PEAR and Zend uses 4 spaces.[16][17] CodeIgniter and WordPress uses tabs.[18][19] PSR-2 specifies 4 spaces.[20]
Python 4 As per PEP-8
Ruby 2 https://github.com/bbatsov/ruby-style-guide#source-code-layout
Rust 4 https://github.com/rust-lang/rust/wiki/Note-style-guide
Scala 2 As per Scala style guide
Tcl 4 As per Tcl style guide
Visual Basic 4 As per Microsoft's Visual Basic Coding Conventions

References[edit]

  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. ^ http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Spaces_vs._Tabs
  4. ^ a b "Indentation : Indent by 2 spaces at a time". Google-styleguide.googlecode.com. Retrieved 2014-02-18. 
  5. ^ "CSS formatting guidelines". Drupal.org. Retrieved 2014-01-18. 
  6. ^ "CSS · Styleguide · GitHub". Github.com. Retrieved 2014-01-18. 
  7. ^ "HaskellStyleGuide - ganeti - Style Guide for the Haskell code - Cluster-based virtualization management software - Google Project Hosting". Code.google.com. 2014-01-08. Retrieved 2014-01-18. 
  8. ^ "HTML Tidy Configuration Options Quick Reference". Tidy.sourceforge.net. 2008-06-18. Retrieved 2014-01-18. 
  9. ^ "Code Conventions for the Java Programming Language: 4. Indentation". Oracle.com. Retrieved 2014-01-18. 
  10. ^ "Code Style Guidelines for Contributors | Android Developers". Source.android.com. Retrieved 2014-01-18. 
  11. ^ "Code Conventions for the JavaScript Programming Language". Javascript.crockford.com. 2006-11-13. Retrieved 2014-01-18. 
  12. ^ "JaveScript Style Rules". Google-styleguide.googlecode.com. Retrieved 2014-02-18. 
  13. ^ "JavaScript 路 Styleguide 路 GitHub". Github.com. Retrieved 2014-01-18. 
  14. ^ jQuery Foundation - jquery.org. "JavaScript Style Guide | Contribute to jQuery". Contribute.jquery.org. Retrieved 2014-01-18. 
  15. ^ "Coding standards". Drupal.org. Retrieved 2014-01-18. 
  16. ^ "Manual :: Indenting and Line Length". Pear.php.net. Retrieved 2014-01-18. 
  17. ^ "PHP Coding Standard (draft) - Contributors - Zend Framework Wiki". Framework.zend.com. Retrieved 2014-01-18. 
  18. ^ "Style Guide : CodeIgniter User Guide". Ellislab.com. Retrieved 2014-01-18. 
  19. ^ "WordPress › PHP Coding Standards « Make WordPress Core". Make.wordpress.org. Retrieved 2014-01-18. 
  20. ^ "PHP : Coding Style Guide". Php-fig.org. Retrieved 2014-02-18.