0

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

ROMANIA_engineer
  • 51,252
  • 26
  • 196
  • 186
TP_JAVA
  • 962
  • 5
  • 21
  • 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
  • 87,251
  • 17
  • 245
  • 186