We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在工程下创建名为.clang-format文件,在其中进行配置
.clang-format
配置选项参考:https://clang.llvm.org/docs/ClangFormatStyleOptions.html
可以通过如下命令快速格式化工程中所有源码
cd project # .clang-format 位于此 fd . 'xxx' -e h 'xxx' -e hpp 'xxx' -e cpp | xargs clang-format -i # 其中xxx替换成想要格式化的目录
注:此命令依赖fd
BasedOnStyle: llvm --- AccessModifierOffset: -4 AlignAfterOpenBracket: Align AlignArrayOfStructures: Right AlignConsecutiveAssignments: Consecutive AlignConsecutiveBitFields: Consecutive AlignConsecutiveDeclarations: Consecutive AlignConsecutiveMacros: Consecutive AlignEscapedNewlines: Left AlignOperands: AlignAfterOperator AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: Empty AllowShortBlocksOnASingleLine: Empty AllowShortEnumsOnASingleLine: true AllowShortIfStatementsOnASingleLine: WithoutElse AllowShortLambdasOnASingleLine: Inline AllowShortLoopsOnASingleLine: true AlwaysBreakTemplateDeclarations: Yes BreakBeforeBinaryOperators: NonAssignment BreakBeforeTernaryOperators: true ColumnLimit: 80 DerivePointerAlignment: false IncludeCategories: - Regex: '<[[:alnum:]_]+>' Priority: 1 - Regex: '<(gtest|gmock)/' Priority: 2 - Regex: '<[[:alnum:]_.]+/[[:alnum:]_.]+>' Priority: 3 - Regex: '<[[:alnum:]_.]+/[[:alnum:]_.]+/[[:alnum:]_./]+>' Priority: 4 - Regex: '.*' Priority: 5 IndentPPDirectives: AfterHash IndentWidth: 4 KeepEmptyLinesAtTheStartOfBlocks: false Language: Cpp PointerAlignment: Right SpaceAfterCStyleCast: false SpaceAfterTemplateKeyword: false SpaceAroundPointerQualifiers: After SpaceBeforeCaseColon: false SpaceBeforeCtorInitializerColon: false SpaceBeforeInheritanceColon: false SpaceBeforeParens: Never SpaceBeforeRangeBasedForLoopColon: false Standard: Latest TabWidth: 4 UseTab: Never
The text was updated successfully, but these errors were encountered:
No branches or pull requests
使用 clang-format 格式化代码
一 创建配置文件
在工程下创建名为
.clang-format
文件,在其中进行配置配置选项参考:https://clang.llvm.org/docs/ClangFormatStyleOptions.html
二 格式化源代码
可以通过如下命令快速格式化工程中所有源码
注:此命令依赖fd
三 附录
3.1 参考配置
The text was updated successfully, but these errors were encountered: