so far I just use tools that don’t change white spaces after the first non-white space character (vim auto-indent) and do the vertical alignment by hand. For trailing comments and assignment operators I’ve seen vertical alignment in clang-format though.
I am not sure one can achieve that with clang-format: did you try? I take the opportunity to advertise a new reference for the ROOT coding style clang-format configuration file: https://root.cern.ch/coding-conventions#ClangFormat
Tried yes, managed no. Though I’m not sure if that’s my inability to configure clang-format correctly or if comma-alignment is just not available with clang-format.
ps: thanks for the pointer to the clang-format settings for the coding conventions.
If you’ve got just one non-struct pod variable in the branch, you can simply omit the third parameter.
So: tree->Branch("Regression_Q2_WORST", &Regression_Q2_WORST, "Regression_Q2_WORST/F");
can become: tree->Branch("Regression_Q2_WORST", &Regression_Q2_WORST);
That doesn’t solve your problem but reduces it by 50%. You could also use a macro if you want to type Regression_Q2_WORST just once (beware of macros!).
Bonus: if you change the type of Regression_Q2_WORST to e.g. Double_t, the code will still be correct. No need to change /F to the new type.
If you want to use clang-format, surround your code with
// clang-format off
... code ...
// clang-format on
thanks for the additions,
I will probably not use macros to keep the code readable and maintainable for non-macro knowers.
I also mostly clang-format small blocks of code interactively in the editor, so no immediate need to protect code from clang-format, as I wouldn’t run it once the code is aligned properly.
But in any case good to have it on record here, maybe somebody else will pick it up!