Eclipse-like comment formatting in IntelliJ IDEA?

前端 未结 7 1736
南方客
南方客 2020-12-11 00:38

In Eclipse, I can format comments by selecting them and pressing Shift + Ctrl + F. For example, when I select a method comment like this:

/**
 *         


        
7条回答
  •  悲哀的现实
    2020-12-11 00:45

    For Javadoc comments, you want to make sure the "Wrap at right margin" setting is checked. See Code Style > JavaDoc, under "Other". However, this setting only seems to take effect when you reformat the whole file, since a reformat of just the Javadoc (i.e., select the Javadoc, then do a Code (menu) > Reformat Code... or CtrlAltL) that exceeds the right margin doesn't force it to wrap. If I reformat the entire file, then it wraps at the margin as expected.

    This seems like a bug (though one that doesn't seem to have been reported), since if you have to set the "Ensure right margin is not exceeded" checked, then selecting the Javadoc text and doing a reformat code does indeed wrap the lines. This setting is in Settings > Code Style > Wrapping and Braces. You can also do a search in the Settings dialog for "ensure right margin".

    You'll still have to manually join the lines using CtrlShiftJ

    This might be worthy of an improvement request to JetBrains.

提交回复
热议问题