Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reformat code style in Eclipse

I'm looking for an automatic way in eclipse to reformat curly braces to K&R style, eliminating braces for single statements if, etc. Is there such a way?

Thanks.

like image 211
Amir Rachum Avatar asked Mar 09 '10 17:03

Amir Rachum


1 Answers

Before you reformat you need to customize the formatter settings in the Preferences Dialog Java/ Code Style / Formatter to your K&R settings if the default settings don't match your requirements.

The Preferences Dialog is opened from Mainmenu / Window / Preferences

You can even configure a save action Java / Editor / Save Action to format source code on save.

like image 76
stacker Avatar answered Sep 19 '22 22:09

stacker