Disable reformatting code when saving files

前端 未结 4 1530

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

4条回答
  •  遥遥无期
    2021-02-02 13:07

    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 
    

    IntelliJ Documentation Link

    If @formatter:off is not working, you can enable it in preferences:

    In IntelliJ Preferences, under Code Style, General, Formatter Control there is a checkbox

提交回复
热议问题