Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - Wrapped lines' indentation appears & disappears each time I save

Each time I click Save the entire file's formatting alternates between these two formats:

this.getObject()
        .method()
        .method();
this.method(arg1, arg2,
        arg3, arg4);

and

this.getObject()
.method()
.method();
this.method(arg1, arg2,
arg3, arg4);

I want it to stick to the first format.

like image 765
Monstieur Avatar asked Apr 23 '14 11:04

Monstieur


People also ask

What is indentation in Java Eclipse?

In programming, indentation is just like formatting. It is used to make the code readable to other users because it makes the code easier to edit, displays how the braces match up, and shows the logic of the program in well-organized fashion.

What is the code for beautify in eclipse?

Go to Source | Format Document or press Ctrl+Shift+F.


1 Answers

I have the same problem with my current Eclipse configuration. I think it is an Eclipse bug.

My guess is that the problem is somewhat related to the option:

Java Code Style -> Cleanup -> Code organizing -> Correct indentation

getting in conflict with

Java Code Style -> Cleanup -> Code organizing -> Format source code

which should already fix indentation according to formatter settings.

I disabled the option Correct indentation in both Java Code Style -> Cleanup and Java Editor -> Save Actions -> Additional Actions -> Configure... and the problem seemed to disappear.

like image 94
user1012976 Avatar answered Oct 11 '22 21:10

user1012976