Clang Format一直这样做:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,
int inSomeIndex,
std::shared_ptr<Something>
inSomething,
int x,
int y );
Run Code Online (Sandbox Code Playgroud)
当我希望它这样做:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,
int inSomeIndex,
std::shared_ptr<Something> inSomething,
int x,
int y );
Run Code Online (Sandbox Code Playgroud)
请注意,它在符号前添加换行符和缩进inSomething.似乎永远是模板化类型导致此行为.
我怎么能阻止它这样做?
这是我目前的.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
Run Code Online (Sandbox Code Playgroud)
编辑:我正在使用我在 2016年7月在github上获得的clang格式Xcode插件(首先在Aclatraz上安装了Alcatraz然后clang格式插件).我不完全确定clang格式二进制文件的位置,因此没有看到插件附带的版本号.
但是,基于下面的建议,我使用Homebrew安装了clang-format,它给了我3.9.0版本.然后我将Xcode插件设置为"使用系统clang-format",我得到了所需的结果,所以我猜它一定是个bug.
你的情况对我来说在ubuntu 16.04上使用clang-format 3.8似乎很好
安装clang-format-3.8
sudo apt-get install clang-format-3.8
Run Code Online (Sandbox Code Playgroud)在 ~/.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>
Run Code Online (Sandbox Code Playgroud)使用@ OP的.clang格式和源代码
mkdir ~/test
vim ~/test/.clang-format
vim ~/test/test.cpp
Run Code Online (Sandbox Code Playgroud)在vim中格式化test.cpp(使用F3),然后得到结果:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,
int inSomeIndex,
std::shared_ptr<Something> inSomething,
int x,
int y );
Run Code Online (Sandbox Code Playgroud)我认为这是由ColumnLimit.我认为这是一个错误...我有这个问题,我通过改变这个变量解决了它.尝试设置:
ColumnLimit: 0
Run Code Online (Sandbox Code Playgroud)
根据bool importSomethingIn( const boost::property_tree::ptree& inBoostTree, int inSomeIndex, std::shared_ptr<Something>" has 117+-3 chars in dependence of computing invisible chars.计算不可见字符,长度为117 + -3.ColumnLimit: 120已经设定,这是可能的原因之一,我认为,它已被削减.
| 归档时间: |
|
| 查看次数: |
913 次 |
| 最近记录: |