ReSharper 2025.3 Help

EditorConfig 属性用于 C++:大括号布局

大括号布局

命名空间声明

属性名称:

[resharper_]cpp_namespace_declaration_braces, [resharper_]cpp_brace_style, [resharper_]namespace_declaration_braces, [resharper_]brace_style

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

namespace ns { void a(); }

end_of_line_no_space

namespace ns{ void a(); }

下一行

namespace ns { void a(); }

下一行缩进

namespace ns { void a(); }

下一行缩进 2

namespace ns { void a(); }

链接规范

属性名称:

[resharper_]cpp_linkage_specification_braces, [resharper_]cpp_brace_style, [resharper_]linkage_specification_braces, [resharper_]brace_style

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

extern "C++" { void a(); }

end_of_line_no_space

extern "C++"{ void a(); }

下一行

extern "C++" { void a(); }

下一行缩进

extern "C++" { void a(); }

下一行缩进 2

extern "C++" { void a(); }

导出声明

属性名称:

[resharper_]cpp_export_declaration_braces, [resharper_]cpp_brace_style, [resharper_]export_declaration_braces, [resharper_]brace_style

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

export { void a(); }

end_of_line_no_space

export{ void a(); }

下一行

export { void a(); }

下一行缩进

export { void a(); }

下一行缩进 2

export { void a(); }

类型声明

属性名称:

[resharper_]cpp_type_declaration_braces, [resharper_]cpp_brace_style, [resharper_]type_declaration_braces, [resharper_]brace_style

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

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

end_of_line_no_space

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

下一行

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

下一行缩进

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

下一行缩进 2

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

将命名空间定义置于同一行中

属性名称:

[resharper_]cpp_place_namespace_definitions_on_same_line[resharper_]place_namespace_definitions_on_same_line

可能的值:

true | false

示例:

true

namespace A { namespace B { void a(); }}

false

namespace A { namespace B { void a(); } }

函数声明

属性名称:

[resharper_]cpp_invocable_declaration_braces, [resharper_]cpp_brace_style, [resharper_]invocable_declaration_braces, [resharper_]brace_style

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

void a() { b(); }

end_of_line_no_space

void a(){ b(); }

下一行

void a() { b(); }

下一行缩进

void a() { b(); }

下一行缩进 2

void a() { b(); }

lambda 表达式

属性名称:

[resharper_]cpp_anonymous_method_declaration_braces, [resharper_]cpp_brace_style, [resharper_]anonymous_method_declaration_braces, [resharper_]brace_style

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

auto a = []() { int x = 0; return x; };

end_of_line_no_space

auto a = [](){ int x = 0; return x; };

下一行

auto a = []() { int x = 0; return x; };

下一行缩进

auto a = []() { int x = 0; return x; };

下一行缩进 2

auto a = []() { int x = 0; return x; };

'case' 标签下的块

属性名称:

[resharper_]cpp_case_block_braces, [resharper_]cpp_brace_style, [resharper_]case_block_braces, [resharper_]brace_style

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

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

end_of_line_no_space

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

下一行

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

下一行缩进

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

下一行缩进 2

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

requires 表达式

属性名称:

[resharper_]cpp_requires_expression_braces[resharper_]requires_expression_braces

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

template <typename T> concept C = requires { typename T::inner1; typename T::inner2; };

end_of_line_no_space

template <typename T> concept C = requires{ typename T::inner1; typename T::inner2; };

下一行

template <typename T> concept C = requires { typename T::inner1; typename T::inner2; };

下一行缩进

template <typename T> concept C = requires { typename T::inner1; typename T::inner2; };

下一行缩进 2

template <typename T> concept C = requires { typename T::inner1; typename T::inner2; };

其他语句和块

属性名称:

[resharper_]cpp_other_braces, [resharper_]cpp_brace_style, [resharper_]other_braces, [resharper_]brace_style

可能的值:

  • end_of_line: 行尾 (K&R 样式)

  • end_of_line_no_space: 行尾(无空格)

  • next_line: 下一行 (BSD 样式)

  • next_line_shifted: 下一行缩进 (Whitesmiths 样式)

  • next_line_shifted_2: 下一行缩进 2 (GNU 样式)

示例:

end_of_line

if (condition) { foo(); } else { foo(); }

end_of_line_no_space

if (condition){ foo(); } else{ foo(); }

下一行

if (condition) { foo(); } else { foo(); }

下一行缩进

if (condition) { foo(); } else { foo(); }

下一行缩进 2

if (condition) { foo(); } else { foo(); }

其他大括号

属性名称:

[resharper_]cpp_expression_braces[resharper_]expression_braces

可能的值:

  • inside :括号内(BSD/K&R 风格)

  • outside :括号和括号内等距(Whitesmiths 风格)

  • outside_and_inside :括号 1x,括号内 2x(GNU 风格)

  • none :无缩进

示例:

inside

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

outside

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

括号外和括号内

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

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

空大括号格式设置

属性名称:

[resharper_]cpp_empty_block_style[resharper_]empty_block_style

可能的值:

  • multiline :分行显示

  • together :将大括号放在一起

  • together_same_line :同一行放在一起

示例:

多行

class C { }; void foo() { for (;;) { } }

一起

class C {}; void foo() { for (;;) {} }

同一行一起

class C {}; void foo() { for (;;) {} }

将简单的复合语句置于一行中

属性名称:

[resharper_]cpp_simple_block_style[resharper_]simple_block_style

可能的值:

  • do_not_change :不更改

  • on_single_line :强制放在单行

  • line_break :强制换行

示例:

do_not_change

int foo() { return 0; }

on_single_line

int foo() { return 0; }

line_break

int foo() { return 0; }

用于开始块的宏的正则表达式

属性名称:

[resharper_]cpp_macro_block_begin[resharper_]macro_block_begin

用于结束块的宏的正则表达式

属性名称:

[resharper_]cpp_macro_block_end[resharper_]macro_block_end

允许在 '{' 后添加注释

属性名称:

[resharper_]cpp_allow_comment_after_lbrace[resharper_]allow_comment_after_lbrace

可能的值:

true | false

示例:

true

if (condition) { // comment statement; }

false

if (condition) { // comment statement; }
最后修改日期: 2025年 12月 8日