ReSharper 2020.2 Help

C++ - Indentation and Alignment

Indentation

Continuous line indent

Property names:

[resharper_]cpp_continuous_line_indent, [resharper_]continuous_line_indent

Possible values:

  • none

  • single

  • double

Examples:

none
int x = foo1() + foo2();
single
int x = foo1() + foo2();
double
int x = foo1() + foo2();

Use continuous line indent in function declaration and invocation parentheses

Property names:

[resharper_]cpp_use_continuous_line_indent_in_method_pars, [resharper_]use_continuous_line_indent_in_method_pars

Possible values:

true | false

Examples:

true
void Method( int parameter1, int parameter2 ) { Method( parameter1, parameter2 ); }
false
void Method( int parameter1, int parameter2 ) { Method( parameter1, parameter2 ); }

Use continuous line indent in initializer lists

Property names:

[resharper_]cpp_use_continuous_line_indent_in_expression_braces, [resharper_]use_continuous_line_indent_in_expression_braces

Possible values:

true | false

Examples:

true
int a[3] = { 1, 2, 3 };
false
int a[3] = { 1, 2, 3 };

Indent namespace members

Property names:

[resharper_]cpp_namespace_indentation, [resharper_]namespace_indentation

Possible values:

  • none: Do not indent

  • inner: Indent only in inner namespaces

  • all: Indent all

Examples:

none
namespace ns { void a(); namespace inner { void b(); }; };
inner
namespace ns { void a(); namespace inner { void b(); }; };
all
namespace ns { void a(); namespace inner { void b(); }; };

Indent linkage specification block members

Property names:

[resharper_]cpp_linkage_specification_indentation, [resharper_]linkage_specification_indentation

Possible values:

  • none: Do not indent

  • inner: Indent only in inner namespaces

  • all: Indent all

Examples:

none
extern "C++" { void a(); extern "C++" { void b(); }; };
inner
extern "C++" { void a(); extern "C++" { void b(); }; };
all
extern "C++" { void a(); extern "C++" { void b(); }; };

Indent access specifier from class

Property names:

[resharper_]cpp_indent_access_specifiers_from_class, [resharper_]indent_access_specifiers_from_class

Possible values:

true | false

Examples:

true
class C { public: void a(); };
false
class C { public: void a(); };

Indent class member from access specifier

Property names:

[resharper_]cpp_indent_class_members_from_access_specifiers, [resharper_]indent_class_members_from_access_specifiers

Possible values:

true | false

Examples:

true
class C { public: void a(); };
false
class C { public: void a(); };

Indent if a function definition or declaration is wrapped after the type

Property names:

[resharper_]cpp_indent_wrapped_function_names, [resharper_]indent_wrapped_function_names

Possible values:

true | false

Examples:

true
void foo() { }
false
void foo() { }

Indent "case" from "switch"

Property names:

[resharper_]cpp_indent_switch_labels, [resharper_]indent_switch_labels

Possible values:

true | false

Examples:

true
switch (expression) { case 0: { foo(); break; } }
false
switch (expression) { case 0: { foo(); break; } }

Indent function declarations' parentheses

Property names:

[resharper_]cpp_indent_method_decl_pars, [resharper_]indent_method_decl_pars

Possible values:

  • inside: Inside parenthesis (BSD/K&R style)

  • outside: Parenthesis and inside equally (Whitesmiths style)

  • outside_and_inside: Parenthesis 1x, inside 2x (GNU style)

  • none: No indent

Examples:

inside
void Method( int parameter1, int parameter2 );
outside
void Method( int parameter1, int parameter2 );
outside_and_inside
void Method( int parameter1, int parameter2 );
none
void Method( int parameter1, int parameter2 );

Indent method calls' parentheses

Property names:

[resharper_]cpp_indent_invocation_pars, [resharper_]indent_invocation_pars

Possible values:

  • inside: Inside parenthesis (BSD/K&R style)

  • outside: Parenthesis and inside equally (Whitesmiths style)

  • outside_and_inside: Parenthesis 1x, inside 2x (GNU style)

  • none: No indent

Examples:

inside
Method( parameter1, parameter2 );
outside
Method( parameter1, parameter2 );
outside_and_inside
Method( parameter1, parameter2 );
none
Method( parameter1, parameter2 );

Indent statement (if, while, for, etc) parentheses

Property names:

[resharper_]cpp_indent_statement_pars, [resharper_]indent_statement_pars

Possible values:

  • inside: Inside parenthesis (BSD/K&R style)

  • outside: Parenthesis and inside equally (Whitesmiths style)

  • outside_and_inside: Parenthesis 1x, inside 2x (GNU style)

  • none: No indent

Examples:

inside
if ( condition1 && condition2 ) return;
outside
if ( condition1 && condition2 ) return;
outside_and_inside
if ( condition1 && condition2 ) return;
none
if ( condition1 && condition2 ) return;

Preprocessor directives indenting

Property names:

[resharper_]cpp_indent_preprocessor_directives, [resharper_]indent_preprocessor_directives

Possible values:

  • none: No indent

  • normal: Indent

  • do_not_change: Do not change

Examples:

none
void sections() { #pragma omp sections { int x; } }
normal
void sections() { #pragma omp sections { int x; } }
do_not_change
void sections() { #pragma omp sections { int x; } }

Indent C++/CLI generic constraints

Property names:

[resharper_]cpp_indent_type_constraints, [resharper_]indent_type_constraints

Possible values:

true | false

Examples:

true
generic<class T1> class C1 where T1 : I1 {};
false
generic<class T1> class C1 where T1 : I1 {};

Indent comments started at the first column

Property names:

[resharper_]cpp_indent_comment, [resharper_]indent_comment

Possible values:

true | false

Examples:

true
namespace N { // Some comment class C1 { }; };
false
namespace N { // Some comment class C1 { }; };

Align Multiline Construct

Declarators in declaration

Property names:

[resharper_]cpp_align_multiple_declaration, [resharper_]align_multiple_declaration

Possible values:

true | false

Examples:

true
int first, second
false
int first, second

Function parameters

Property names:

[resharper_]cpp_align_multiline_parameter, [resharper_]align_multiline_parameter

Possible values:

true | false

Examples:

true
double average(double first, double second);
false
double average(double first, double second);

Call arguments

Property names:

[resharper_]cpp_align_multiline_argument, [resharper_]align_multiline_argument

Possible values:

true | false

Examples:

true
object.method(first, second);
false
object.method(first, second);

First call argument by '('

Property names:

[resharper_]cpp_align_first_arg_by_paren, [resharper_]align_first_arg_by_paren

Possible values:

true | false

Examples:

true
object.method( first, second);
false
object.method( first, second);

Initializer list arguments

Property names:

[resharper_]cpp_align_multiline_expression_braces, [resharper_]align_multiline_expression_braces

Possible values:

true | false

Examples:

true
int a[6] = {1, 2, 3 4, 5, 6};
false
int a[6] = {1, 2, 3 4, 5, 6};

Template parameters in template declaration

Property names:

[resharper_]cpp_align_multiline_type_parameter, [resharper_]align_multiline_type_parameter

Possible values:

true | false

Examples:

true
template <typename K, typename V> struct map;
false
template <typename K, typename V> struct map;

Template arguments

Property names:

[resharper_]cpp_align_multiline_type_argument, [resharper_]align_multiline_type_argument

Possible values:

true | false

Examples:

true
std::map<char*, MyStruct> my_map;
false
std::map<char*, MyStruct> my_map;

Base classes in class base clause

Property names:

[resharper_]cpp_align_multiline_extends_list, [resharper_]align_multiline_extends_list

Possible values:

true | false

Examples:

true
struct MyStruct : Base1, Base2 { };
false
struct MyStruct : Base1, Base2 { };

Member initializers in member initializer lists

Property names:

[resharper_]cpp_align_multiline_ctor_init, [resharper_]align_multiline_ctor_init

Possible values:

true | false

Examples:

true
struct MyStruct { MyStruct() : first(f), second(s) { } };
false
struct MyStruct { MyStruct() : first(f), second(s) { } };

Outdent commas

Property names:

[resharper_]cpp_outdent_commas, [resharper_]outdent_commas

Possible values:

true | false

Examples:

true
class Class< T1 , T3> : Base , SomeInterface { void fooCall( int firstParameter , int secondParameter) { fooCall( firstParameter , secondParameter); } }
false
class Class< T1 , T3> : Base , SomeInterface { void fooCall( int firstParameter , int secondParameter) { fooCall( firstParameter , secondParameter); } }

?: operator

Property names:

[resharper_]cpp_align_ternary, [resharper_]align_ternary

Possible values:

  • align_all: Align

  • align_not_nested: Align except when nested

  • none: No align

Examples:

align_all
int var = 56 + (cond1 ? result1 : cond2 ? result2 : result3);
align_not_nested
int var = 56 + (cond1 ? result1 : cond2 ? result2 : result3);
none
int var = 56 + (cond1 ? result1 : cond2 ? result2 : result3);

Chained method calls

Property names:

[resharper_]cpp_align_multiline_calls_chain, [resharper_]align_multiline_calls_chain

Possible values:

true | false

Examples:

true
struct X { X foo(X x) { x.foo() .foo() .foo(); } };
false
struct X { X foo(X x) { x.foo() .foo() .foo(); } };

Outdent "." and "->" in chained method calls

Property names:

[resharper_]cpp_outdent_dots, [resharper_]outdent_dots

Possible values:

true | false

Examples:

true
auto a = MyVar .SomeMethod() ->OtherMethod() .ThirdMethod(); auto b = MyVar .SomeMethod() ->OtherMethod() .ThirdMethod();
false
auto a = MyVar .SomeMethod() ->OtherMethod() .ThirdMethod(); auto b = MyVar .SomeMethod() ->OtherMethod() .ThirdMethod();

Chained binary expressions

Property names:

[resharper_]cpp_align_multiline_binary_expressions_chain, [resharper_]align_multiline_binary_expressions_chain

Possible values:

true | false

Examples:

true
int var = 1 + 2 + 3;
false
int var = 1 + 2 + 3;

Align Similar Code In Columns

Assignments

Property names:

[resharper_]cpp_int_align_eq, [resharper_]int_align_eq

Possible values:

true | false

Examples:

true
const char* x = "x"; SomeClass xxxxx = "xxxxx"; int xxx; int& y = xxx;
false
const char* x = "x"; SomeClass xxxxx = "xxxxx"; int xxx; int& y = xxx;

Declaration names

Property names:

[resharper_]cpp_int_align_declaration_names, [resharper_]int_align_declaration_names

Possible values:

true | false

Examples:

true
const char* x = "x"; SomeClass xxxxx = "xxxxx"; int xxx; int& y = xxx;
false
const char* x = "x"; SomeClass xxxxx = "xxxxx"; int xxx; int& y = xxx;

End comments

Property names:

[resharper_]cpp_int_align_comments, [resharper_]int_align_comments

Possible values:

true | false

Examples:

true
void foo() { DoSomething(); // I'm auto y = 6; // forced while (y > 0) y--; // to DoSomethingElse(); /* document */ auto z = 10; /* my code */ while (z < 100) z++; /* profusely */ }
false
void foo() { DoSomething(); // I'm auto y = 6; // forced while (y > 0) y--; // to DoSomethingElse(); /* document */ auto z = 10; /* my code */ while (z < 100) z++; /* profusely */ }
Last modified: 08 May 2020