开发者

Is there any way to have all local variables aligned in Eclipse?

Eclipse has a great feature to allow you to align all your 'fields in columns' meaning that it will turn:

开发者_如何学Go
int myVar = 2334;
int asdf = 34;
String s = "hello";

into

int     myVar  = 2334;
int     asdf   = 34;
String  s      = "Hello";

This makes the code a lot more readable and I love it. However I can't seem to find a similar setting to make it do that for regular local variables. Anyone know if there is a way? It'd be a shame if there isn't one.

Thanks


If you go in Eclipse's settings, Java -> Code Style -> Formatter, you may edit or create a new profile.

Anyway, in the Indentation tab, there is an "Align fields in columns" option that should do what you are looking for.


Window --> Preferences --> Java --> Code Style --> Formatter

  1. Create a New Profile
  2. check Align fields in columns
  3. click ok
  4. Select all variables declared.
  5. Ctrl + Shift + F
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜