问题
Is there a way to configure Eclipse code formatter for C/C++ to Align fields in columns
//without formatting
int mRect = 0;
int mSquare = 0;
bool isTriangle = false;
//to look like this???
int mRect = 0;
int mSquare = 0;
bool isTriangle = false;
For Java I found this Eclipse: Auto-align "=" in assignments
回答1:
I tried with OCDFormat.jar as described at https://stackoverflow.com/a/18491579, and it works for C++ too.
It would be still nice if we can do this with native eclipse formatter.
回答2:
The Eclipse plugin columns4eclipse should do the trick (gratis, open source, I use it with Eclipse 4.3 x64 and 4.5 x64 on Windows 7). It is not language-dependent.
(OCDFormat is ok too though a bit less flexible and there is an issue with some (common) operators).
来源:https://stackoverflow.com/questions/30104147/align-field-in-columns-c-c