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
Today in 2020 IDEA is silently formatting HTML before commit, which might break your web pages appearance. To disable that unselect this checkbox:
Settings | Editor | General > Other | Strip trailing spaces on Save -> None.
For newer versions (at least WebStorm 2018), Ctrl + S
is bound to a save Macro that has a reformat code action followed by save.
You can remove this reformat with Ctrl + Shift + A
search for Macro
then modify the save
one.
Edit | Macros | Edit Macros | save | - on the Action: Reformat...
You can add these comments to make it temporarily disable formatting on the file, or a specific function:
// @formatter:off
If you want one section to remain, you can also add this:
// @formatter:on
If @formatter:off
is not working, you can enable it in preferences: