Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove unused import and variable on save action in eclipse

Tags:

eclipse

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.

like image 753
Lakhwinder Sharma Avatar asked Aug 28 '13 06:08

Lakhwinder Sharma


People also ask

How do I delete unnecessary imports in Eclipse?

Eclipse provide a shortcut CTRL + SHIFT + O, this shortcut command will remove all those unused imports from your code file.

How do I remove unused variables in Eclipse?

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).


1 Answers

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!

like image 139
Bambara Avatar answered Oct 12 '22 18:10

Bambara