Reputation: 1129
I've started using Java again recently and I'm setting up my dev environment in eclipse which has a handy format function that formats the code for you. This is great cause I've been able to set the settings to fit my code standard almost perfectly except for local variable declaration. I like to keep my declarations lined up (there is even an option for class parameter declaration that does what I want)
Here is what I would like :
void jad()
{
int alpha = 1;
String beta = "jad";
MyOwnObject SomeReallyLongName = new MyOwnObject();
}
Instead, eclipse's format gives me :
void jad()
{
int alpha = 1;
String beta = "jad";
MyOwnObject SomeReallyLongName = new MyOwnObject();
}
I don't mind if it doesn't format it the way I want it too, I would just love it if it didn't remove the whitespaces that I put there myself >.< (if it can do it for me, that would be even better of course).
Anybody know how to get eclipse to do something like this? (couldn't find any option in the Code Style editor)
Upvotes: 4
Views: 625
Reputation: 19443
Actually the formatter will do this alignment for you. Go into Preference -> Java -> Code Style -> Formatter and Edit the profile. Look at the Indentation tab, there will be an option to Align Fields in Columns.
But it just aligns the class, not the method variables, so not what you want.
Upvotes: 1