<p>In Eclipse, under <kbd>Windows</kbd> -> <kbd>Preference</kbd> -> <kbd>Java</kbd> -> <kbd>Code Style</kbd>, you can define code templates for comments and code, and you can setup a code formatter. </p>

<p>I'm wondering if it is possible in Eclipse to have these setting take affect every time I save a source file.  Basically, instead of me highlighting everything and pressing <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>F</kbd>, I want Eclipse to be responsible for making sure my code is formatted properly.</p>

<p>Is this possible and how do you set it up?</p>

<p><strong>Note On Using the Auto-Format:</strong>  It's probably best to choose "Format Edited Lines" as merging changes becomes very difficult when you reformat a whole file that is in source control already that was not formatted properly. Already did this to a co-worker.</p>

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
```
```