How to tell astyle to bracket one line for and while loops?

263 Views Asked by At

astyle allows bracketing one line conditional statements using the option j. So, the code:

// test.cpp
if (x == 0) break;

can be formatted using the command:
astyle -j test.cpp to format test.cpp as:

if (x == 0)
{
  break;
}

Suppose, I need the fragment:

for (int i = 0; i < 10; i++) if (x == 5) break;

to be formatted as:

for (int i = 0; i < 10; i++)
{
  if (x == 5)
  {
     break;
  }
}

how do I accomplish it using astyle? And, similarly for while() loop?

0

There are 0 best solutions below