Eclipse Tip: Automatic Cleanup On Save

Probably not a new tip for everyone, but here's how to have the Eclipse Java editor cleanup your code whenever you save a file. In the preferences, navigate to Java > Editor > Save Actions, activate the checkbox "Perform the selected actions on save", and check anything you like. For example, the screenshot shows what to activate to never leave unused import statements behind.

Eclipse Preferences

I'd advise against using "Format source code" and "Remove trailing whitespace", though. While those sound nice in theory, they tend to irritate source code comparison for obvious reasons.

Maik Schreiber

Maik Schreiber

Fri Jul 09 01:45:00 CEST 2010 • Fri Jul 09 01:45:00 CEST 2010

Eclipse, Java

Categories

Sophora CMS - A New Take on Content Management

Sophora is optimized to meet the needs of modern companies that produce up-to-date multimedia content on a large scale and that require fast delivery of their content.

Toromiro

Toromiro is a professional tool for the administration and editing of Java Content Repositories (JCR). JCR is powering some of today’s most successful solutions for content management and digital asset management.