Every IDE has cool features which help us writing cleaner and more organized code. Let’s improve our code style in eclipse!

Step 1 – import the code style file

Save the file containing the code style and compiler settings: codewing_codestyle.epf
Import it in Eclipse with File > Import > (General >) Preferences
On the next page select the file you downloaded before, make sure ‘Import all’ is selected and hit finish.

If everything went right you can see the new profile named “codewing.de” as an active profile in the formatter window
(Window > Preferences > Java > Code Style > Formatter)
Click on “Edit…” and do the following:

  • Go to the “Line Wrapping” tab and set “Set line width for preview window” to 180 (instead of 40).
  • Go to the “New Lines” tab and check the box which labels “Insert new line after type annotations”.

Leave by hitting apply.

Step 2 – save actions

Head to Window > Preferences > Java > Editor > Save Actions and make sure it looks like below…
Hint: You don’t have to do it exactly as I did, because everyone has own preferences so un-/check whatever you want. This is only how I did it.

SaveActions

Let’s configure some of the additional actions (> Configure)

CodeOrganizing

CodeStyle

MemberAccesses

MissingCode

UnneccessaryCode

Don’t forget to hit Apply and OK!

Step 3 – global / lokal settings

Make sure that project specific settings are only used where you need them.

Right click on your project(s) Preferences > Java > Code Style > Formatter and make sure that “Enable project specific settings” is NOT selected.

That’s it!
Have fun and happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.