Remove trailing whitespace on save in IntelliJ IDEA 12
In 2020.1 IntelliJ version:
File -> Settings -> Editor -> General -> then scroll down to 'Save Files'
Don't know about 12, but there's the following setting in 13:
Settings → Editor → Strip trailing spaces on Save
As of IntelliJ 2017.2 it's under
Settings → Editor → General → Strip trailing spaces on Save