Customize save action in Eclipse IDE

Published on 06/23/2024

It is very common for me, as a freelance, to work on software existent since many years and to collaborate with teams with different coding rules.

It is not uncommon to work on projects that haven’t a clear coding style policy.

In the latter scenario it is particularly important to avoid the introduction of accidental coding style rules.

Eclipse IDE permits to customize very well the actions to perform on saving.

In one of my last collaborations I decided for example to remove automatically unused import (to maintain the code clean) on saving but avoiding the default action suggested by Eclipse: the imports re-ordering. To do this you have to:

  1. Access to Window > Preferences > Java > Editor > Save Actions. screen Eclipse 1
  2. Select Perform the selected actions on save. screen Eclipse 2
  3. Unselect Organize imports. screen Eclipse 3
  4. Select Additional actions. screen Eclipse 4
  5. Click Configure. screen Eclipse 5
  6. Remove all default enabled actions.
  7. Tab Unnecessary Code. screen Eclipse 6
  8. Select Remove unused imports. screen Eclipse 7

Screenshots are related to Eclipse 2024-03 but it can generally applied to older version too.

  • Article is published under CC-BY 4.0
  • If not explicitly declared code snippets are published under MIT license