Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable reformatting code when saving files

Tags:

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 almost every line has unnecessary white space that gets cleaned up. Now it appears the entire file was modified even though I only made a small fix. This will make looking at the significant changes in VCS more difficult.

Is there a way to disable code reformatting when a file gets saved? So far I haven't had any luck finding the setting in the Project Settings dialog. I'm using IntelliJ IDEA 9.0.2

Alternatively I could perform the reformat, commit the changes, and then make my modification but I feel that this will end up happening a lot and I don't want to impose my formatting preferences on code owned by other groups.

like image 495
Keith Avatar asked Jun 04 '10 19:06

Keith


People also ask

Why is VSCode formatting on save?

You have configured prettier to format as per the default settings. If you don't see the code formatted automatically on file save then it might be because you have multiple formatters installed in VS Code.

How do I stop auto alignment in VS code?

ctrl + shift + P.

How do I turn off auto format in Intellij?

In Preferences > Editor > Code style > [language] uncheck reformat on file save .


1 Answers

Settings | Editor | General > Other | Strip trailing spaces on Save -> None.


Updated for IntelliJ Idea 2021+

Settings | Editor | General > On Save | Remove trailing spaces on: <...> -> None.

like image 133
CrazyCoder Avatar answered Sep 20 '22 14:09

CrazyCoder