- Actions on save -> checked,
- Reformat changed lines -> checked
- Optimize imports -> checked.
This works excellently most of the time, but sometimes I want my own formatting to remain.
I seem to remember that if you do Cmd + Z immediately after save, the IDE would revert the auto code formatter and save the file (maybe from Eclipse?) But IntelliJ undoes the reformatting and marks the file as unsaved, when saving it will do the reformat again. I press Cmd + Z again, code is how I want it, Cmd + S auto format again. I failed to find a way out of this loop, unless I disable "reformat changed lines" from "actions on save". But most of the time I want that.
How can I undo the auto reformat and save the file? I don't want to use formatter markers.
- Actions on save -> checked,
- Reformat changed lines -> checked
- Optimize imports -> checked.
This works excellently most of the time, but sometimes I want my own formatting to remain.
I seem to remember that if you do Cmd + Z immediately after save, the IDE would revert the auto code formatter and save the file (maybe from Eclipse?) But IntelliJ undoes the reformatting and marks the file as unsaved, when saving it will do the reformat again. I press Cmd + Z again, code is how I want it, Cmd + S auto format again. I failed to find a way out of this loop, unless I disable "reformat changed lines" from "actions on save". But most of the time I want that.
How can I undo the auto reformat and save the file? I don't want to use formatter markers.
Share Improve this question edited Mar 14 at 7:35 jonrsharpe 122k30 gold badges268 silver badges476 bronze badges asked Mar 14 at 7:29 Bogdan PopBogdan Pop 1016 bronze badges1 Answer
Reset to default 0You need to do the setting to remove that behavior first, that you can find at
Settings > Tools > Actions on Save
Uncheck the Reformat code , you can pick some file types to apply this or not.