Java - Eclipse - How to Automatically Format Java Code / How to add format template xml


Step 1 

Go to Windows -> Preferences -> Java -> Code Style -> Formatter

Step 2 

Import your own formatting template or use eclipse built in formatter.

Step 3 

Press Ok.

Step 4 

Select your Code and hit CTRL +SHFT + F to format the code as per configuration specified.