There's an option that you can set to do this on save:
You can add this to your File Settings -- User config file under the preferences menu.
// Set to true to removing trailing white space on save
All of the default options can be found in the ***Settings -- Default** files in that same menu. To customize any of them copy just the ones you care about into the User settings file of the same name and override them.