仅当当前行溢出clang格式时,才能在新线路上支撑
Brace on new line only if current line overflows clang format
我最近决定将.clang-format
文件包括在我的C 项目中,以使代码更加均匀且易于阅读。我通常喜欢Google默认值,除了我想使用4个空间凹痕而不是两个。
问题是,当当前行溢出80个字符列限制时,它使某些语句更难读取。例如,在if语句中溢出:
if (some_condition || some_other_condition ||
yet_another_condition) {
// block starts here
}
yet_another_condition
的对齐与if-block的开始匹配,这使得在没有某种休息的情况下很难阅读。理想情况下,在这种情况下我想发生的事情就是这样:
if (some_condition || some_other_condition ||
yet_another_condition)
{
// block starts here
}
但是,当当前行溢出到下一个时,我只希望在新线路上的开放支架,就像上面的示例一样。在所有其他情况下,我都希望在同一行上开放支架(用于/for/for/why/while/while/switch等。语句以及功能)。
可以在保留其余的Google默认设置完整时在我的.clang-format
文件中指定此行为?
clang-format工具允许用BraceWrapping: Custom
指定自定义支撑包装,但它的灵活性不够灵活,无法意识到所需的上下文。
提高可读性的替代解决方案是使用大于4的持续凹痕,例如ContinuationIndentWidth: 8
。
相关文章:
- 在挂钩启动新线程时解除挂钩进程
- 如何检查第三个 API 是否在 Linux 中为 c/c++ 程序创建了一个新线程?
- 是否需要在 Timer.5 boost::asio 教程中运行新线程?
- SetTimer (带有回调函数)是否通过启动新线程来工作?
- Zmq 上下文 - 我应该在新线程中创建另一个上下文吗?
- 函数如何在不这样做的情况下在新线程上运行"as if"?
- 从 VS2013 到 VS2017 std::async 不会启动新线程
- 从传递给新线程C++的矢量中删除项目
- c++ 从成员函数创建新线程并移动对象和整个对象
- 如何从.txt文件中读取多个2D数组,而无需每个之间的新线
- 在新线程C++中发送 http 请求
- 在新线程中访问移动的 std::string
- 使用新线程在类似于 Scott Meyer 的单例习惯用法的实现中实例化单例是否安全?
- 如何从const char *类型字符串中删除新线字符
- 仅当当前行溢出clang格式时,才能在新线路上支撑
- Winapi:在类成员功能上创建新线程 - 不兼容的参数类型
- 使用新线程池而无需重新启动的新线程池后,Jemalloc的内存大大增加
- C++ std::async 不会生成新线程
- 如何从新线程 QML QT c++ 更改文本字段
- Strtok如何处理新线