OiO.lk Blog C# Eclipse formatting for array initializer with long names
C#

Eclipse formatting for array initializer with long names


I’m using Eclipse 4.29.0 CDT (STM32CubeIDE) to write C code and have a curious behavior with the auto formatting feature. Arrays with numbers or short element names are formatted as expected (first one) arrays with long initializer names (second one) not. Especially the single element in the beginning of the line is distracting.

  uint8_t my_defines_array[] = { NUM1, NUM1, NUM1, NUM3, NUM1, NUM1, NUM3, NUM1, NUM3, NUM1, NUM3, NUM1, NUM3, NUM8, NUM8, NUM5, NUM1, NUM3, NUM8, NUM8, NUM5,
                                 NUM1, NUM3, NUM8, NUM8, NUM5, NUM1, NUM3, NUM3, NUM8, NUM8, NUM5, NUM1, NUM3, NUM8, NUM8, NUM5, NUM1, NUM3 };

  uint8_t my_long_names_array[] = { NUM_NUM_NUMBER3, NUM_NUM_NUMBER3, NUM_NUM_NUMBER3, NUM_NUM_NUMBER3, NUM_NUM_NUMBER3, NUM_NUM_NUMBER3, NUM_NUM_NUMBER3,
  NUM_NUM_NUMBER3,
                                    NUM_NUM_NUMBER3, NUM_NUM_NUMBER3, NUM_NUM_NUMBER3, NUM_NUM_NUMBER3 };

Is there a special setting that I’m missing to avoid this?

My used settings:
Line Wrapping – Expressions – Initializer list:

  • Line wrapping only when necessary
  • No force split
  • Indent on column



You need to sign in to view this answers

Exit mobile version