5

Using the Uncrustify tool I would like to apply the 1TBS style, which places braces like this:

if (x < 0) {
    printf("Negative");
}

How do I do this? I can't seem to find the right options.

Rafa Viotti
  • 9,998
  • 4
  • 42
  • 62
Jim Blackler
  • 22,946
  • 12
  • 85
  • 101
  • What do you mean by "opening braces to share the previous code line?" Opening braces to be on the same line (not alone on a line)? Or something else? Perhaps provide an example of undesirable formatting? – Peter Mortensen Aug 26 '22 at 14:48

2 Answers2

4

I think you need to set nl_if_brace to ignore/add/remove/force.

Also, check the sp_else_brace and sp_brace_else options. Set it to 1, otherwise your code will end up with code such as:

if (condition){

instead of

if (condition) {
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
phi
  • 10,634
  • 6
  • 53
  • 88
0

There's a tool called UniversalIndentGui that lets you play with Uncrustify's various tersely-worded settings and see immediate impact on a block of sample code.

Screenshots of UniversalIndentGUI

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Scott McCoy
  • 308
  • 2
  • 13