5

Here is a javadoc comment that I wrote:

  /**
   * This utility allows the user to do the following.
   * <ul>
   *   <li>A cool feature</li>
   *   <li>Another cool feature</li>
   * </ul>
   */
  public static void main(String[] args) {

Here is the same comment, reformatted by intelliJ

  /**
   * This utility allows the user to do the following.
   * <ul>
   * <li>A cool feature</li>
   * <li>Another cool feature</li>
   * </ul>
   */
  public static void main(String[] args) {

How can I prevent the autoformat feature from clobbering my intentations?


In order to prevent IntelliJ from removing my newlines, I checked a box:

Settings > Editor > Code Style > Java > JavaDoc > Preseve Line Feeds

I wish there was a "Preseve leading whitespace" box in the same place, but there isn't.

MatrixManAtYrService
  • 8,023
  • 1
  • 50
  • 61
  • 1
    Try advice from this answer https://youtrack.jetbrains.com/issue/IDEA-90692#comment=27-373981 – Petr Rastegaev Nov 24 '17 at 15:04
  • 1
    Actually, whitespace/indent removal applies to anything in Javadocs for IntellJ. For example, if you have `` fragment with properly indented source code inside Javadocs, IntelliJ wipes spaces out. Upvote for "reserve leading whitespaces" checkbox. – uvsmtid Jun 19 '20 at 04:23
  • Googling helped for my `` case - see [this answer](https://stackoverflow.com/a/542142/441652). IntelliJ does not remove whitespaces if `@code` tag is used. But this HTML case still remains as it's not part of code but rich text formatting. – uvsmtid Jun 19 '20 at 04:31

0 Answers0