Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Eclipse, when activating the option "Align fields in columns" (which I want) in Window -> Preferences -> Java -> Formatter ("Indentation" tab), Eclipse also decides to align the closing brace of any assigned block (array initializer, anonymous class, static initializer...) on the column of the equal sign as well, as follows:

int    myVar      = 0;
int[]  myArray    = {
    1, 2, 3, 4, 5, 6
                  };

Whereas if you uncheck the "Align fields in columns" option, you get:

int myVar = 0;
int[] myArray = {
    1, 2, 3, 4, 5, 6
};

Ideally, I'd like the following hybrid (maybe with the possibility to define the indentation of the closing brace):

int    myVar      = 0;
int[]  myArray    = {
    1, 2, 3, 4, 5, 6
};

I tried to play with the options in the "Line Wrapping" tab as well, but they do not seem to impact this. (Eclipse even lies to you as you can in the "Whitespace" tab's option for "Array Initializers" something that looks like I want, but probably because it considers it a local varaible.

Also, if someone knows of a magic way to have the "align fields on columns" equivalent for local variables, that could be interesting.

Unfortunately, as of Eclipse 3.4 to 3.7, I never found a way to do this perfectly, which prevents me from using the auto-formatter to its full potential.

Clues and suggestions are welcome, even in the form of custom plug-ins, patches, or other arcane solutions.

share|improve this question
    
Not sure if that would be more suited for StackOverflow.com. Let me now. –  haylem May 25 '11 at 11:48
    
stackoverflow.com/questions/151034/… –  user118750 Feb 16 '12 at 19:25
    
@Peter: thanks, but I'm afraid you misread my question as your link points to a solution to achieve what I already have in my first case, which is NOT what I want. (otherwise, it would be easy :) –  haylem Feb 19 '12 at 4:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.