Search code examples
c++eclipseautoformattingautoformat

Indenting function braces in Eclipse


I am working on a C++ project and using Eclipse as the IDE. The coding standards for the project specify indenting the initial and closing braces for a function, as in:

int main()
  {
  return 0;
  }

Is there an option in Eclipse 4.3.1 to automatically indent this way?


Solution

  • Use the main menu to Navigate to Window->Preferences.

    On the resulting dialog, expand your way to C/C++->Code Style->Formatter. Set Active Profile to Whitesmiths and edit to taste.

    enter image description here

    For example, it looks like you want to set Indentation size and Tab size on the Indentation tab to 2.

    enter image description here