Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ column code formatting

I am trying to change up the IntelliJ code formatting options to improve the clarity and readability of my code. Two problems I have come across are the following:

1) Creating columns in an array. What I have:

private int[][] c = new int[][]{
        {1, 2, 3},
        {100, 200, 300}    
};

What I would want:

private int[][] c = new int[][]{
        {  1,   2,   3},
        {100, 200, 300}    
};

2) Aligning parenthesis on multiple lines in binary operations. What I have:

final int argb = (red << 0) |
                 (green << 8) |
                 (blue << 16) |
                 (alpha << 24);

What I would want:

final int argb = (red   <<  0) |
                 (green <<  8) |
                 (blue  << 16) |
                 (alpha << 24);

If anyone knows of any way this can be done, that would be greatly appreciated. I did not see any options available that seemed to have worked. Maybe there is a weird combination I need. I can provide the current Code Style settings I have. Thanks for the help.

like image 325
Obicere Avatar asked Mar 12 '26 17:03

Obicere


1 Answers

There's a plugin for that, called Tabifier, available in the default plugin repository. It haasn't been updated in 3 years, but it seems to still work.

It has extensive configuration and does a lot of controversial layouts, so I recommend turning most of its features off at first, and then slowly enable ones that you need.

The main downside is that the default Reformat Code action ignores whatever Tabifier did, so you would have to manually retabulate chunks of code from time to time

like image 154
Karol S Avatar answered Mar 15 '26 05:03

Karol S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!