How to have the formatter wrap code with IntelliJ?

后端 未结 7 1335
梦谈多话
梦谈多话 2020-12-22 17:31

I\'m not able to format my code in IntelliJ.

I can see the margin line (by default at 120 columns) but it seems that the activation from the menu:

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-22 18:17

    You can create a macro for Ctrl +Shift + S (for example) that do all this things:

    Edit > Macros > Start Macro Recording (the recording will start). Click where you need.

    For example:

    Code > Reformat Code
    Code > Auto-Indent Lines
    Code > Optimize Imports
    Code > Rearrange Code
    File > Save All
    ... (all that you want)
    

    Then, click on red button in bottom-right of the IDE to stop the Macro recording.

    Set a macro name.

    Go to File > Settings > Macros > YOUR MACRO NAME.

    Right Click > Add Keyboard Shortcut, and type Ctrl + Shift + S.

提交回复
热议问题