Stop code format from removing spaces in eclipse

I recently started using Java, and I am setting up my eclipse environment, which has a convenient format function that formats the code for you. This is a great reason why I was able to set the settings to my code standard almost perfectly, except for declaring a local variable. I like it when my ads line up (there is even an option to declare a class parameter that does what I want)

Here is what I would like:

void jad() { int alpha = 1; String beta = "jad"; MyOwnObject SomeReallyLongName = new MyOwnObject(); } 

Instead, the eclipse format gives me:

 void jad() { int alpha = 1; String beta = "jad"; MyOwnObject SomeReallyLongName = new MyOwnObject(); } 

I don’t mind if he doesn’t format it the way I want it, I would just like it if he didn’t remove the spaces that I put there>. <(if he can do this for me, it would be even better, of course).

Does anyone know how to get an eclipse to do something like this? (could not find any parameter in the Code Style editor)

+4
source share
1 answer

In fact, the formatter will do this alignment for you. Go to Preferences -> Java -> Code Style -> Formatter and edit the profile. Look at the Indent tab, the option "Align fields in columns" will appear.

But it just aligns the class, not the method variables, so not what you want.

+1
source

All Articles