Eclipse code formatting is not aligning fields in columns properly

自作多情 提交于 2019-12-11 06:58:58

问题


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:

  1. Go to Window --> Preferences --> General --> Appearance --> Colors and Fonts and then to Basic --> Text Font
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!