Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What option should be used to remove extra spaces using astyle?

How can I remove extra spaces from my code using astyle? For example I want to convert the following code:

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

to this:

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

But astyle is currently converting it to this:

void foo (int  a  ,  int   c)
{
    d   = a +      c;
}
like image 788
B Faley Avatar asked Nov 01 '22 02:11

B Faley


1 Answers

There is currently no way to unpad the spaces around operators in astyle. If there had been a way to unpad the operators, you could have first unpadded the spaces, and then again pad them using -p option.

--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--);

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

like image 172
Pradyumna Newalkar Avatar answered Nov 15 '22 04:11

Pradyumna Newalkar