问题
Eclipse code formatter is not aligning fields equally with Align fields in columns option checked when field is of type int
or boolean
. Here's how it shows up after formatting:
private Rect mTempRect;
private int lastClickX;
private int lastClickY;
private int mMaxLinesCount;
private boolean mWrapped;
private boolean expanded;
private SpannableString mLinkHideText;
I'm using Eclipse Version: 4.2.1 JUNO x64, Ubuntu 12.04 LTS 64 bits.
回答1:
Solved!
The problem was that Eclipse was using a variable width font so that white spaces got different widths when code formatted. Solved changing the font to a fixed size one.
Reference: Different the width of whitespace in eclipse editor
回答2:
I did this:
- Go to Window --> Preferences --> General --> Appearance --> Colors and Fonts and then to Basic --> Text Font
- Change font from Monospace 8 to Liberation Mono 8.
That works for me.
来源:https://stackoverflow.com/questions/13503309/eclipse-code-formatting-is-not-aligning-fields-in-columns-properly