Tabifier

Compatible with IntelliJ IDEA
25.04.2015
20 772
The tabifier plugin retabs Java code so that syntactic elements are aligned vertically. Extensive, configurable control over alignment is provided. [Note: the following examples are aligned correctly when viewed within IDEA's plugin manager, but are misaligned when viewed on the JetBrains plugin repository page due to the use of a non-fixed font.]

For example, I like to align variable declarations and assignment statements like this:

               int          v1;                  // loop variable
               String       s2;                  // second string
public  static PrintWriter  p;
private static boolean      debugging    = true; // initialize
private static OutputStream outputstream = null;

outputstream = new FileOutputStream(f, true);
p            = new DebuggingPrintWriter(outputstream, true);
        
IDEA likes to format them with single spaces separating the syntactic elements, like this:
int v1; // loop variable
String s2; // second string
public static PrintWriter p;
private static boolean debugging = true; // initialize
private static OutputStream outputstream = null;

outputstream = new FileOutputStream(f, true);
p = new DebuggingPrintWriter(outputstream, true);
        
The tabifier plugin automatically reformats the text into the first version, or any variation of it you choose.

The Tabifier is able to right justify integer literals, e.g.

public static final int ONE    =  1;
public static final int TWO    =  2;
public static final int TEN    = 10;
public static final int ELEVEN = 11;
        
It can align method declaration and method call parameters, even with multiple parameters per line:
public ExpressionListParser(TokenColumn       openParend,
                            ColumnChoice      params,
                            TokenColumn       closeParend,
                            CodeStyleSettings codeStyleSettings, TabifierSettings settings,
                            NestedParser      parser,            int              nestingLevel)
        
And its expression alignment is recursive, e.g.
if ((psiExpressionList.getExpressions().length               >  expressionListIndex &&
     psiExpressionList.getExpressions()[expressionListIndex] == child                 ) ||
    (sawNoParameters                                         == false               &&
     expressionListIndex                                     >                    0   )   )
        
It is capable of reformatting "if" statements as follows:
if (param1 == p3 &&
    j      >  5     ) p3 = 7;
....
if      (param1 == p3) p3     = 6;
else if (param1 == 2 ) method1(param1, true, 3);
else                   param1 = 7;
        
Method calls can be reformatted to align parentheses, commas, or parameters:
align_params                    = (ColumnSetting ) find(ALIGN_PARAMS              );
align_semicolon                 = (ColumnSetting ) find(ALIGN_SEMICOLON           );
align_semicolon_with_comma      = (BooleanSetting) find(ALIGN_SEMICOLON_WITH_COMMA);
        
Typecast parentheses and types as well as many other expression components can also be aligned.

Download plugin

Recent change notes

New release of Tabifier (5.9.1) fixes binary expression alignment problem.