score:210

Accepted answer

under preferences, choose java --> editor --> save actions. check the perform the selected actions on save, and check the format source code box.

this may or may not be available in previous versions of eclipse. i know it works in:

version: 3.3.3.r33x_r20080129-_19uel7ezk_gxf1kouft<br>
build id: m20080221-1800

score:2

if you find that you do not have a save actions preference under java--> editor, it may be because you are using an older version of eclipse. in that case you can install the format on save plugin from here.

then, under preferences, choose java --> format on save. select the run format option under select a code formatting action

score:13

i have a snapshot of the setting. please follow the path:

in the preferences window, choose java --> editor --> save actions.

check the perform the selected actions on save, and check the format source code box.

enter image description here

score:15

i strongly recommend checking your eclipse format xml descriptor into source control. that way all members of the team can use it and you don't get to and fro reformatting battles.


Related Query

More Query from same tag