Clang格式一直这样做:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,int inSomeIndex,std::shared_ptr<Something> inSomething,int x,int y );
当我想要这样做:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,std::shared_ptr<Something> inSomething,int y );
请注意,它是在符号之前添加一个换行符和缩进.它似乎始终是导致此行为的模板类型.
如何阻止这样做?
这是我当前的.clang格式:
BasedOnStyle: LLVM Language: Cpp AccessModifierOffset: -4 AlignEscapedNewlinesLeft: false AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortFunctionsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: true AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: false BinPackParameters: false BreakBeforeBinaryOperators: false BreakBeforeBraces: Allman BreakBeforeTernaryOperators: false BreakConstructorInitializersBeforeComma: false ColumnLimit: 120 CommentPragmas: '' ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DerivePointerAlignment: false DerivePointerBinding: false ExperimentalAutoDetectBinPacking: false IndentCaseLabels: true IndentFunctionDeclarationAfterType: true IndentWidth: 4 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: false MaxEmptyLinesToKeep: 2 NamespaceIndentation: All ObjCBlockIndentWidth: 4 ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: true PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left PointerBindsToType: true SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: true Standard: Cpp11 TabWidth: 8 UseTab: Never
编辑:我使用cl格式Xcode插件,我获得了here在github 2016年7月(首先安装了阿尔卡特拉德然后ang格式插件与Aclatraz).我不完全确定clang格式二进制文件的位置,因此没有看到插件附带的版本号.
但是,根据下面的建议,我使用Homebrew安装了clang格式,它给了我3.9.0版本.然后我将Xcode插件设置为“使用系统clang-format”,并得到所需的结果,所以我猜这是一个bug.
解决方法
在ubuntu 16.04上,您的情况似乎很好,cl格式3.8
>安装clang-format-3.8
sudo apt-get install clang-format-3.8
>在〜/ .vimrc
map <F3> :pyf /usr/share/vim/addons/Syntax/clang-format-3.8.py<cr> imap <F3> <C-o>:pyf /usr/share/vim/addons/Syntax/clang-format-3.8.py<cr>
>使用@ OP的.clang格式和源代码
mkdir ~/test vim ~/test/.clang-format vim ~/test/test.cpp
>在vim中格式化test.cpp(使用F3),然后结果:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,int y );