c++ - 应该使用什么选项来使用 astyle 删除多余的空格?

标签 c++ formatting coding-style code-formatting astyle

如何使用 astyle 从我的代码中删除多余的空格?例如我想转换以下代码:

void foo (     int  a  ,  int   c )
{
d   = a+      c;
}

为此:

void foo (int a, int c)
{
    d = a + c;
}

但 astyle 目前正在将其转换为:

void foo (int  a  ,  int   c)
{
    d   = a +      c;
}

最佳答案

目前无法在 astyle 中取消填充运算符周围的空格。如果有办法取消运算符的填充, 您可以先取消填充空格,然后再次使用 -p 选项填充它们。

--pad-oper / -p

Insert space padding around operators.

Any end of line comments will remain in the original column, if possible.

Note that there is no option to unpad. Once padded, they stay padded.

if (foo==2)
    a=bar((b-c)*a,d--);

becomes:

if (foo == 2)
    a = bar((b - c) * a, d--);

来源:http://astyle.sourceforge.net/astyle.html#_pad-oper

关于c++ - 应该使用什么选项来使用 astyle 删除多余的空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30680314/

相关文章:

c++ - 如何使用 tesseract 对文档中的多列进行 OCR

c++ - 如何修复 `Any` 类代码以正确输出数据?

c++ - 如何在unordered_map::const_iterator中使用typedef?

c++ - 如何检测像素图边缘透明的两个 QGraphicsPixmapItem 之间的碰撞?

java - Java 中的 String.format() 和十六进制数字

PHP if else - 正确使用 "else"

c# - 关于从嵌套语句返回的快速问题

c# - 读取文本文件并继续格式化

java - 如何在 JTextArea 中均匀地分隔二维数组而不使用\t?

java - 为什么人们使用 if(null == var) 风格的测试?