Disable reformatting code when saving files

瘦欲@ 提交于 2019-12-03 11:33:17

问题


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.


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/2977324/disable-reformatting-code-when-saving-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!