Configuring Formatting Style for C/C++/Fortran Projects
See Also
You can use the Options window to configure default formatting style for your C and C++
projects.
To configure C and C++ formatting style:
-
Choose Tools > Options.
-
Click Editor in the top pane of the window.
-
Click the Formatting tab.
-
Select the language for which you want to set formatting style from the Language list.
-
Select the style you want to set from the Style list.
-
Modify the style properties as desired.
To add a style:
-
Click Manage, then click New in the Manage Styles dialog box.
To remove a custom style:
-
Click Manage, then select the style and click Remove in the Manage Styles dialog box.
To duplicate a style:
-
Click Manage, select a style in the Manage Styles dialog box and click Duplicate.
You can set the following properties:
-
Indents:
-
Indent Size. Number of spaces per indent.
-
Statement Continuation Indent. Specifies the shift for the second and subsequent
lines in a multiline statement.
-
Preprocessor Directives Indent. Lets you specify whether preprocessor directives
are not indented, indented independently of code, or use the indent from the preceding
code.
-
# at Start Line. Lets you specify whether the # that is the first symbol of a
preprocessor directive is in the first column or in the indent column.
-
Indent Namespaces. Lets you forbid indenting of namespaces.
-
Indent Case Statements in Switch. Lets you specify the switch indent, or the
switch indent plus the indent size, for indentation of case statements in a switch.
-
Absolute Label Indentation. Lets you specify whether labels are in the first
column or indented by an enclosing statement.
-
Braces Placement. Lets you choose whether braces should be placed on a new line or
the same line for namespace declarations, class/struct declarations, method/function
declarations, blocks, and compound statements.
-
Multiline Alignment. Lets you choose whether to have multiline alignment for method
parameters, method call arguments, and array initializers.
-
New Line. Lets you choose whether to have catch, else, and while statements on new
lines.
-
Spaces Before Keywords. Lets you choose whether to have spaces before the following
keywords: if, for, while, catch, switch.
-
Spaces Before Parentheses. Lets you choose whether to have spaces before parentheses
in function declarations, function calls, catch statements, for statements, if statements,
switch statements, and while statements.
-
Spaces Around Operators. Lets you choose whether to have spaces around assignment
operators, binary operators, ternary operators, and unary operators.
-
Spaces Before Left Braces. Lets you choose whether to have spaces before left braces
in class declarations, function declarations, array initializers, catch statements, do
statements, else statements, for statements, if statements, switch statements, try
statements, and while statements.
-
Spaces Within Parentheses. Lets you choose whether to have spaces within parentheses
in function declaration, function calls, array initializer brackets, braces, parentheses,
catch statements, for statements, if statement, switch statements, type casts, and while
statements.
-
Other Spaces. Lets you choose whether to have spaces before commas, after commas,
before semicolons, after semicolons, before colons, after colons, and after type casts.
-
Blank Lines. Lets you choose whether to have a blank line before a class, after a
class header, and before a function.
-
Other. Lets you choose whether to add a leading star in comments.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.