Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can GNU indent be made to format a while (or for, ...) statement to a single line?

My indent (GNU indent 2.2.11) outputs this

while (a == b)

I'd like it to output one single line instead. I tried a lot of the options but haven't been able to come up with the right combination (it it's at all possible) yet.

while (a == b) b++;
for (i = 0; i < 100; i++) arr[i] = i;
share|improve this question

I can't do it using indent but using uncrustify. With:

uncrustify --show-config

you can see its configuration options, then you have to create the file ~/.uncrustify.cfg where you'll define your style. For what concerns your issue you must put in your configuration file:

nl_create_if_one_liner    True
nl_create_for_one_liner   True
nl_create_while_one_liner True

See man uncrustify to learn how to invoke uncrustify.

share|improve this answer
+1 Thank you cYrus. I've installed uncrustify and played a bit with it. I'll be testing it more deeply in the coming days. – pmg Oct 5 '10 at 18:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.