Search code examples
intellij-idea

IntelliJ Optimize Imports for the entire scala project


One of the very useful features of IntelliJ is that when I am done editing a file, I can do a "optimize imports". this removes all the unused imports from my code.

This is very useful, but I have to do it for every file.

Can I do "optimize imports" for the entire project?


Solution

  • Select the source root in the project tree;

    1. Hit the keyboard shortcut for "Optimize import"

    MAC

    Cmd-shift-A 
    

    Windows

    Ctrl-shift-A 
    

    2. You will see

    dialog of auto import

    3. Hit Run