How to correct indentation in IntelliJ

后端 未结 7 1622
逝去的感伤
逝去的感伤 2020-12-04 10:18

How can indentation be automatically (not manually) corrected in IntelliJ?

In Eclipse, it\'s possible to just highlight the code that needs indenting, right-click, a

7条回答
  •  -上瘾入骨i
    2020-12-04 10:56

    Solution of unchecking comment at first column is partially working, because it works for line comments, but not block comments.

    So, with lines like:

    /* first line
     * second line
     * ...
     */
    

    or

    // line 1
    // line 2
    // line 3
    ...
    

    they are indented with "Auto reformat", but lines like:

    /* first line
       second line
       ...
     */
    

    the identation will not be fixed.

    So you should:

    • add * or // before each line of comments
    • then uncheck Keep when reformatting -> comment at first column
    • and Auto reformat.

提交回复
热议问题