clang-format - Clang 格式结构初始化 - 缩进两个空格?
问题描述
我正在尝试使用 clang-format 格式化 C 文件。我希望缩进是两个空格字符,除了在全局变量结构初始化中之外,它主要工作。为此,它继续生成以四个空格缩进的行。
这是我的 .clang 格式文件
BasedOnStyle: LLVM
ColumnLimit: '80'
IndentWidth: '2'
clang-format 产生了这个令人惊讶的输出
typedef struct {
int x;
} foo;
static foo bar{
1, // This line is being indented with 4 spaces!
};
这就是我期望文件的样子:
typedef struct {
int x;
} foo;
static foo bar{
1, // This line is being indented with 2 spaces!
};
我尝试对 使用几个不同的值ConstructorInitializerIndentWidth
,但该字段似乎不会影响此模式。
有没有我可以提供的设置来获得这种行为?
解决方案
试试ContinuationIndentWidth: 2
。当我遇到这个问题时,这对我有用。
推荐阅读
- php - Laravel 验证是否已经存在具有相似两列组合的记录
- android - 在移动设备上保存数据的最佳方式是什么?
- paypal - 返回商家
- mysql - SQL - 尝试在现有表中插入新列,其中值从 50 开始自动递增 1
- javascript - 服务出错时如何重定向到错误组件?
- node.js - UnhandledPromiseRejectionWarning:错误:无效登录:535 身份验证失败:用户名/密码错误
- c# - 具有范围的 Asp.net core 2.1 OpenIdConnectOptions 不起作用
- python - 如何使用硒从“ui_bubble_rating bubble_50”中提取数字
- javascript - firebase.firestore.FieldValue.arrayUnion 不是函数
- spring - 在 Spring Boot Mongodb 中使用聚合框架按计数查找组