Is there a way for all local variables to be aligned in Eclipse?

Eclipse has an excellent feature that allows you to align all your fields in columns, which means that it will look like:

int myVar = 2334; int asdf = 34; String s = "hello"; 

in

 int myVar = 2334; int asdf = 34; String s = "Hello"; 

It makes the code more readable and I like it. However, I cannot find a similar setting to do this for ordinary local variables. Does anyone know if there is a way? It would be a shame if not for one.

thanks

+6
code-formatting eclipse
source share
2 answers

If you go to the Eclipse settings, Java → Code Style → Formatter, you can edit or create a new profile.

In any case, the Indentation tab has the option "Align fields in columns", which should do what you are looking for.

+4
source share

Window → Settings → Java → Code Style → Formatter

  1. Create a new profile
  2. check alignment of fields in columns
  3. click ok
  4. Select all declared variables .
  5. Ctrl + Shift + F
0
source share

All Articles