I made a small change to an old java file in IntelliJ and when I save the file the IDE automatically reformats all the code. Normally this would be preferable, however it seems
Settings | Editor | General > Other | Strip trailing spaces on Save -> None.