Is there a way to make the java eclipse formatter not align the @param descriptions?

Tags: , , ,



I am trying to change the settings of the Eclipse formatter so that it doesn’t align the indentation of the param tag descriptions.

This is what I am aiming for:

/**
 * Creates a new CTScanData object holding the data from the given file path.
 *
 * @param dataFilePath Path to the file containing the CT scan data.
 * @param width Width of the scan data (left to right).
 * @param depth Depth of the scan data (front to back).
 * @param height Height of the scan data (top to bottom).
 */

And this is what the formatter is currently doing:

/**
 * Creates a new CTScanData object holding the data from the given file path.
 *
 * @param dataFilePath Path to the file containing the CT scan data.
 * @param width        Width of the scan data (left to right).
 * @param depth        Depth of the scan data (front to back).
 * @param height       Height of the scan data (top to bottom).
 */

I have tried changing a couple of setting with no luck.

  1. In the Eclipse formatter editor I disabled the “Indent description after @param” and “Indent Javadoc tags”.
  2. In the exported XML file, I found org.eclipse.jdt.core.formatter.comment.indent_parameter_description set as false. I also tried making this true, but it made no difference.

Note: I’m using the formatter in Visual Studio Code, but I don’t think it should make any difference compared to using it in Eclipse? After each change I restarted Visual Studio Code to make sure that the changes were applied.

Answer

Make sure you have the following in .settings/org.eclipse.jdt.core.prefs for that:

org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false


Source: stackoverflow