-1
  • 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.

1 Answer 1

0

You 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.

Sign up to request clarification or add additional context in comments.

2 Comments

Look like there is no other way but disable and enable
Yes. You can always reformat code by using the hotkeys of intellij. Or if you need the standard on the remote repository, tools like eslint (on JS Code) is another good option to put on pre-push/pre-commit hook.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.