0

How to set reformat and remove unused imports upon file save( Ctrl + S) in IntelliJ version 12.2?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
TP_JAVA
  • 1,002
  • 5
  • 23
  • 49

1 Answers1

5

When working in IntelliJ IDEA, files are always saved automatically by the IDE. Because of that, there is no need to ever press Ctrl-S, and therefore IntelliJ IDEA does not provide a way to execute actions when files are saved.

Unused imports can be removed automatically directly as files are being edited: Settings | Editor | Auto Import | Optimize imports on the fly

Reformatting code automatically can be performed before a VCS commit; there's a corresponding checkbox in the Commit Changes dialog.

yole
  • 92,896
  • 20
  • 260
  • 197