- sln同级目录下,放一个clang-format文件

- vs插件设置

- 安装format on save 插件并启用.

下面是.clang-format文件是从qt-creator抄的,改变了一下括号的换行.
# .clang-format for Qt Creator## This is for clang-format >= 5.0.## The configuration below follows the Qt Creator Coding Rules [1] as closely as# possible. For documentation of the options, see [2].## Use ../../tests/manual/clang-format-for-qtc/test.cpp for documenting problems# or testing changes.## In case you update this configuration please also update the qtcStyle() in src\plugins\clangformat\clangformatutils.cpp## [1] https://doc-snapshots.qt.io/qtcreator-extending/coding-style.html# [2] https://clang.llvm.org/docs/ClangFormatStyleOptions.html#---Language: CppAccessModifierOffset: -4AlignAfterOpenBracket: AlignAlignConsecutiveAssignments: falseAlignConsecutiveDeclarations: falseAlignEscapedNewlines: DontAlignAlignOperands: trueAlignTrailingComments: trueAllowAllParametersOfDeclarationOnNextLine: trueAllowShortBlocksOnASingleLine: falseAllowShortCaseLabelsOnASingleLine: falseAllowShortFunctionsOnASingleLine: InlineAllowShortIfStatementsOnASingleLine: falseAllowShortLoopsOnASingleLine: falseAlwaysBreakAfterReturnType: NoneAlwaysBreakBeforeMultilineStrings: falseAlwaysBreakTemplateDeclarations: trueBinPackArguments: falseBinPackParameters: falseBraceWrapping:AfterClass: trueAfterControlStatement: falseAfterEnum: falseAfterFunction: trueAfterNamespace: falseAfterObjCDeclaration: falseAfterStruct: trueAfterUnion: falseBeforeCatch: falseBeforeElse: trueIndentBraces: falseSplitEmptyFunction: falseSplitEmptyRecord: falseSplitEmptyNamespace: falseBreakBeforeBinaryOperators: AllBreakBeforeBraces: CustomBreakBeforeInheritanceComma: falseBreakBeforeTernaryOperators: trueBreakConstructorInitializersBeforeComma: falseBreakConstructorInitializers: BeforeCommaBreakAfterJavaFieldAnnotations: falseBreakStringLiterals: trueColumnLimit: 120CommentPragmas: '^ IWYU pragma:'CompactNamespaces: falseConstructorInitializerAllOnOneLineOrOnePerLine: falseConstructorInitializerIndentWidth: 4ContinuationIndentWidth: 4Cpp11BracedListStyle: trueDerivePointerAlignment: falseDisableFormat: falseExperimentalAutoDetectBinPacking: falseFixNamespaceComments: trueForEachMacros:- forever # avoids { wrapped to next line- foreach- Q_FOREACH- BOOST_FOREACHIncludeCategories:- Regex: '^<Q.*'Priority: 200IncludeIsMainRegex: '(Test)?$'IndentCaseLabels: falseIndentWidth: 4IndentWrappedFunctionNames: falseJavaScriptQuotes: LeaveJavaScriptWrapImports: trueKeepEmptyLinesAtTheStartOfBlocks: false# Do not add QT_BEGIN_NAMESPACE/QT_END_NAMESPACE as this will indent lines in between.MacroBlockBegin: ""MacroBlockEnd: ""MaxEmptyLinesToKeep: 1NamespaceIndentation: NoneObjCBlockIndentWidth: 4ObjCSpaceAfterProperty: falseObjCSpaceBeforeProtocolList: truePenaltyBreakAssignment: 150PenaltyBreakBeforeFirstCallParameter: 300PenaltyBreakComment: 500PenaltyBreakFirstLessLess: 400PenaltyBreakString: 600PenaltyExcessCharacter: 50PenaltyReturnTypeOnItsOwnLine: 300PointerAlignment: RightReflowComments: falseSortIncludes: trueSortUsingDeclarations: trueSpaceAfterCStyleCast: trueSpaceAfterTemplateKeyword: falseSpaceBeforeAssignmentOperators: trueSpaceBeforeParens: ControlStatementsSpaceInEmptyParentheses: falseSpacesBeforeTrailingComments: 1SpacesInAngles: falseSpacesInContainerLiterals: falseSpacesInCStyleCastParentheses: falseSpacesInParentheses: falseSpacesInSquareBrackets: falseStandard: Cpp11TabWidth: 4UseTab: Never
