如何在访问修饰符后实现以下缩进:
class A{
public:
int a;
}
应该导致
class A
{
public:
int a; // note the indentation
}
clang-format只允许访问修饰符与int a
AccessModifierOffset: 0
处于同一级别,从而导致
class A
{
public:
int a;
}
答案 0 :(得分:2)
在我工作的地方,我们偶然发现了相同的问题。由于IndentWidth
参数在所有位置(类,函数等)都控制缩进,因此您试图实现的目标似乎是不可能的。我认为,下一个最好的方法是保留IndentWidth=4
并设置AccessModifierOffset=-2
。
这样您就可以:
class Foo
{
public:
Foo() = default;
};
bool foo()
{
return true;
}
答案 1 :(得分:0)
根据clang-format documentation,doCheckSomething("whatever")
.then(resultingJson => {
// Do whatever you need with the /doCheck data.
})
.catch(console.error) // Print errors, in case there are any.
正是为此目的而设计的。用responseJson
和AccessModifierOffset
格式化您的代码示例,我得到了以下输出:
AccessModifierOffset: -4