目录
UE4源码工程的代码规范使用的是EditorConfig。
官方网址:EditorConfig
好处是:VS默认支持EditorConfig,不用下载插件。
示例文件:.editorconfig
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Baseline
[*]
charset = utf-8
indent_style = tab
indent_size = 4
tab_width = 4
trim_trailing_whitespace = false
max_line_length = 120
# MSBuild
[*.{csproj,proj,projitems,shproj,fsproj,target,props}]
indent_style = space
indent_size = 2
# XML config files
[*.{config,nuspec,resx,natvis}]
indent_style = space
indent_size = 2
# Python files
[*.py]
indent_style = space
indent_size = 4
Clang-format使用
1. 从 LLVM Download Page 下载安装文件。
- 注意提前沟通好团队使用的版本。
- 安装是勾选 add Path
2. 在VS上进行设置。Tools->Options
3. 配置文件放在工程目录下。(.clang-format)
-
--- Language: Cpp BasedOnStyle: LLVM IndentWidth: 4 UseTab: Never Standard: Cpp11 BreakBeforeBraces: Allman PointerAlignment: Left AccessModifierOffset: -4 AllowShortFunctionsOnASingleLine: None ColumnLimit: 80 CompactNamespaces: false SortIncludes: false FixNamespaceComments: true SpacesBeforeTrailingComments: 1 SpaceBeforeParens: ControlStatements SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: false SpaceBeforeInheritanceColon: true BinPackParameters: false ...
4. 格式方式:Edit->Advanced->
- Format Document (Shift+Alt+F)
- Format Selection (Ctrl+D,Ctrl+F)