Skip to content

Instantly share code, notes, and snippets.

@robinvanyang
Last active June 1, 2024 18:22
Show Gist options
  • Save robinvanyang/e627354190cdbf56644bded24f70c9be to your computer and use it in GitHub Desktop.
Save robinvanyang/e627354190cdbf56644bded24f70c9be to your computer and use it in GitHub Desktop.
clang格式化配置文件
# config from: https://www.jianshu.com/p/4311cea76a10
# option infomation doc:
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
---
# BasedOnStyle: LLVM
---
Language: Cpp
BasedOnStyle: Google
Standard: Cpp11
AccessModifierOffset: -4
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Mozilla
ColumnLimit: 160
ContinuationIndentWidth: 4
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
---
Language: JavaScript
# Use 100 columns for JS.
ColumnLimit: 100
@robinvanyang
Copy link
Author

robinvanyang commented May 18, 2024

在整个工程层面禁用include自动排序方法: 在 .clang-format 中加入选项: SortIncludes:false

只是在文件中的某些特定区域禁用include自动排序,参照下面代码:

// clang-format off
#include <b.h>
#include <a.h>
#include <c.h>
// clang-format on
#include <d.h>
#include <e.h>

参考:

https://stackoverflow.com/a/60334432/1372066

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment