home

Not all developers classify the options provided by Uncrustify in the same way:
- Some think in term of keyword: if, while, switch, struct, etc.
- Others think in term of action: where to add a space, where to add a line break, etc.
- Some don't want to use options that modify the code, such as adding/removing brackets or curly braces.

But, as a developer, you know that to rule you have to divide!
Currently you have 3 tools for that:

First tool: include

Uncrustify offers a little-known tool (because it is not used in the configurations examples) to divide:

    include file

which works the same way as #include "file"
Example:

  $ cat uncrustify.cfg
  include path/to/general.cfg
  include path/to/kr_statements.cfg
  include path/to/expression.cfg

  $ cat kr_statements.cfg
  include kr/for_do_while.cfg
  include kr/class_struct_enum_union.cfg
  include kr/if_else_switch.cfg
  include kr/throw_try_catch.cfg

Second tool: reuse

You know the syntax used by uncrustify configuration:
  <option-name> = <value>
Example: nl_after_annotation = force

In fact the syntax is:
  <option-name> = <value> | <option-name>
Obviously, the option on the left side and the one on the right side must have the same type.
Examples:

  input_tab_size = 4
  output_tab_size= input_tab_size
  indent_columns = output_tab_size

  # --> Change the value of 'nl_do_brace' between 'remove' or 'force'

                                  #-- remove --------- force ---------
  nl_do_brace     = remove        # "do {"         vs  "do \n {"
  nl_brace_while  = nl_do_brace   # "} while"      vs  "} \n while"

  nl_for_brace    = nl_do_brace   # "for () {"     vs  "for () \n {"

  nl_if_brace     = nl_do_brace   # "if () {"      vs  "if () \n {"
  nl_elseif_brace = nl_do_brace   # "else if {"    vs  "else if \n {"
  nl_brace_else   = nl_do_brace   # "} else"       vs  "} \n else"
  nl_else_brace   = nl_do_brace   # "else {"       vs  "else \n {"

  nl_switch_brace = nl_do_brace   # "switch () {"  vs  "switch () \n {"

  nl_try_brace    = nl_do_brace   # "try {"        vs  "try \n {"
  nl_catch_brace  = nl_do_brace   # "catch () {"   vs  "catch () \n {"
  nl_brace_catch  = nl_do_brace   # "} catch       vs  "} \n catch"

  nl_while_brace  = nl_do_brace   # "while () {"   vs  "while () \n {"

Third tool...

... this documentation ;-)


home