MTSU
  Indenting and Spacing

There is a semantic way of using tab characters and spaces in C++ source code: use tabs for indentation and use spaces for alignment. This ensures that the code is displayed correctly everywhere, regardless of the viewer's tab size.

    // Tab size: 4                // Tab size: 2
    if (foo)                      if (foo)
    {                             {
    --->int arr[4] = {0, 1,       ->int arr[4] = {0, 1,     // "0" and "2"
    --->..............2, 3};      ->..............2, 3};    // remain aligned
    }                             }

Thus:
1. Tabs are only used at the beginning of lines. Everything else, like ASCII art and tables, should be formatted with spaces.
2. Tabs are only used for expressing the indentation level. One tab per "block"---any remaining whitespace is spaces only.


Tabs and spaces are often misunderstood. (Original comic by Steve Napierski.)
TabsSpacesBoth

This page is an edited excerpt of the page http://www.emacswiki.org/emacs/SmartTabs.