Eric
Eric

Reputation: 1444

Indentation of comments in eclipse

Eclipse lines up my Java line comments three spaces to the left of the code lines, so that the words of the comment line up to the code, and not the slashes, for example:

for (int i = 0; i < count; i++) {
    Foo foo1 = new Foo();
 // This is a comment.
    Foo foo2 = new Foo();
}

I don't want it to do that. ;o) I looked in the Java->Code Style->Formatter profile, but I couldn't find what is making it do that (I assumed something on the Indentation or Comments tabs, but I didn't find anything).

Does anyone know where that setting could be hidden so I can get those comments lining up to the code?

Upvotes: 3

Views: 1821

Answers (1)

Amit Bhati
Amit Bhati

Reputation: 5649

"Click on window--> preferences --> type formatter --> Select Formatter in code style under java --> Click on edit (in active profile) --> Unselect "Enable line comment formatting"

enter image description here

Eclipse doesn't allow to make changes to in-built formatter, you need to create a new profile for your formatter. Refer the link: How to change in-built formatter settings. In the new profile just un-select the checkbox mentioned above in screenshot.

Upvotes: 5

Related Questions