Customize save action in Eclipse IDE
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:
- Access to Window > Preferences > Java > Editor > Save Actions.
- Select Perform the selected actions on save.
- Unselect Organize imports.
- Select Additional actions.
- Click Configure.
- Remove all default enabled actions.
- Tab Unnecessary Code.
- Select Remove unused imports.
Screenshots are related to Eclipse 2024-03 but it can generally applied to older version too.