Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Luna – AutoIndent is inconsistent

I upgraded to Luna and have a problem with auto-formatting, more specifically auto-indentation. The About Eclipse dialog verifies that I am running 4.4.0.

When the code auto-indents on save, it seems to jump back and forth between two different ways of indenting it regarding the number of spaces. Note the level of indentation:

doSomething( "arg0",
    "arg1" );

and

doSomething( "arg0",
        "arg1" );

This is extremely annoying when using SCM like git. What's causing this? How can it be fixed?

like image 319
Ingo Bürk Avatar asked Jun 25 '14 19:06

Ingo Bürk


People also ask

How do I fix indentation in STS?

You can use Ctrl + Shift + F which will run your formatter on the file and fix indentations along the way also.


1 Answers

I found this bug reported here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=434962

The fix mentioned there is to uncheck "Correct indentation" in the save actions. Weirdly, it will still correct indentation, but the bug is gone.

Update: Eclipse Mars also has some issues. One bug can be found here. As a workaround, see here how to use the old formatter in Mars.

like image 108
Ingo Bürk Avatar answered Sep 19 '22 11:09

Ingo Bürk