How can I remove unused import and variable on save action in eclipse. I have option Ctrl+Shift+O. but it remove only unused import. I want to remove unused variable also.
Eclipse provide a shortcut CTRL + SHIFT + O, this shortcut command will remove all those unused imports from your code file.
You can delete all unused variables of a selected area: Open the source code editor of the development object. Select the code where you want to delete the unused variables. From the context menu, choose Source > Delete Unused Variables (Selection) (Ctrl + Shift U).
Here is how you can do it:
In Eclipse Go to Window -> Preferences-> Java -> Editor -> Save Actions and click on Perform the selected actions on save: Organize imports.
Enjoy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With