clang-format configurator - 交互式创建 ClangFormat 格式化配置文件
2026/7/22 22:12:10 网站建设 项目流程

clang-format configurator - 交互式创建 ClangFormat 格式化配置文件

  • 1. clang-format configurator
  • 2. clang-format configurator v2
  • 3. Clang-Format Style Options
    • 3.1. AlignEscapedNewlines (EscapedNewlineAlignmentStyle)
    • 3.2. SortIncludes (SortIncludesOptions)
    • 3.3. AlwaysBreakBeforeMultilineStrings (Boolean)
    • 3.4. AlwaysBreakTemplateDeclarations (deprecated)
    • 3.5. AccessModifierOffset (Integer)
  • References

1. clang-format configurator

clang-format configurator
https://zed0.co.uk/clang-format-configurator/

clang-format-configurator
https://github.com/zed0/clang-format-configurator

Interactively create a clang-format configuration while watching how the changes affect your code.
以交互方式创建 clang-format 配置,同时观察更改如何影响你的代码。

2. clang-format configurator v2

clang-format configurator v2
https://clang-format-configurator.site/

Clang-format-configurator-v2
https://github.com/Wirena/clang-format-configurator-v2

Interactively create a clang-format configuration while watching how the changes affect your code.

Clang-format-configurator-v2 is a written from scratch successor of clang-format-configurator.

3. Clang-Format Style Options

https://clang.llvm.org/docs/ClangFormatStyleOptions.html

Clang-Format Style Options describes configurable formatting style options supported by LibFormat and ClangFormat.

3.1. AlignEscapedNewlines (EscapedNewlineAlignmentStyle)

Options for aligning backslashes in escaped newlines.
在转义换行符中对齐反斜杠的选项。

Possible values:
ENAS_DontAlign(in configuration:DontAlign) Don’t align escaped newlines.
不要对齐转义的换行符。

#define A \ int aaaa; \ int b; \ int dddddddddd;

ENAS_Left(in configuration:Left) Align escaped newlines as far left as possible.
尽可能向左对齐转义的换行符。

#define A \ int aaaa; \ int b; \ int dddddddddd;

ENAS_Right(in configuration:Right) Align escaped newlines in the right-most column.
在最右边的列中对齐转义的换行符。

#define A \ int aaaa; \ int b; \ int dddddddddd;

3.2. SortIncludes (SortIncludesOptions)

Controls if and how clang-format will sort#includes.

Nested configuration flags:

Includes sorting options.

  • bool EnabledIftrue, includes are sorted based on the other suboptions below. (Neveris deprecated byEnabled: false.)

  • bool IgnoreCaseWhether or not includes are sorted in a case-insensitive fashion. (CaseSensitiveandCaseInsensitiveare deprecated byIgnoreCase: falseandIgnoreCase: true, respectively.)

true: false: #include "A/B.h" vs. #include "A/B.h" #include "A/b.h" #include "A/b.h" #include "a/b.h" #include "B/A.h" #include "B/A.h" #include "B/a.h" #include "B/a.h" #include "a/b.h"

bool IgnoreExtensionWhen sorting includes in each block, only take file extensions into account if two includes compare equal otherwise.

true: false: # include "A.h" vs. # include "A-util.h" # include "A.inc" # include "A.h" # include "A-util.h" # include "A.inc"

3.3. AlwaysBreakBeforeMultilineStrings (Boolean)

Iftrue, always break before multiline string literals.

This flag is mean to make cases where there are multiple multiline strings in a file look more consistent. Thus, it will only take effect if wrapping the string at that point leads to it being indentedContinuationIndentWidthspaces from the start of the line.

true: false: aaaa = vs. aaaa = "bbbb" "bbbb" "cccc"; "cccc";

3.4. AlwaysBreakTemplateDeclarations (deprecated)

This option is renamed to BreakTemplateDeclarations.

3.5. AccessModifierOffset (Integer)

The extra indent or outdent of access modifiers, e.g.public:.

References

[1] Yongqiang Cheng (程永强), https://yongqiang.blog.csdn.net/
[2] clang-format configurator - 交互式创建 ClangFormat 格式化配置文件, https://mp.weixin.qq.com/s/q9PNNl0l8Xmf6ZAwUphzbw

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询