How enable auto-format code for Intellij IDEA?

后端 未结 15 1117
小鲜肉
小鲜肉 2020-12-22 17:05

Is it possible in Intellij IDEA after typing \';\' or press \'Enter\' happened formatting of this string?

For instance, to:

a+b=10;

15条回答
  •  我在风中等你
    2020-12-22 17:42

    The way I implemented automatical reformating like in Microsoft Visual Studio (It doesn't work perfect):

    1. Edit > Macros > Start Macro Recording
    2. Press continuously: Enter + Ctrl+Alt+I
    3. Edit > Macros > Stop Macro Recording (Name it for example ReformatingByEnter)
    

    Now we need to perform same actions but for Ctrl+Alt+L+;

    4. Edit > Macros > Start Macro Recording
    5. Press continuously: ; + Ctrl+Alt+I
    6. Edit > Macros > Stop Macro Recording (Name it for example ReformatingBy;)
    

    Now we need to assign HotKeys to these macros:

    7. File > Settings > Keymap > press on a gear button > Duplicate...
    8. Unfold a macro button (beneath) and by right clicking on two 
    ours macros assign HotKeys for them: "Enter" and ";" correspondingly.
    

提交回复
热议问题