3

Which eclipse-formatter setting in vscode will accomplish the following formatting, focusing specifically on the parameter alignment?

Current

    public ResponseEntity retrieveAgreement(final String one, final Long someId,
            final Long anotherId, final Long otherPAram) {
        // Omitted
    }

Desired

    public ResponseEntity retrieveAgreement(final String one, 
                                            final Long someId,
                                            final Long anotherId, 
                                            final Long otherParam) {
        // Omitted
    }
Albert Scholtz
  • 337
  • 3
  • 15

2 Answers2

3

About Java Formatting, you can refer to Formatting and Linting.

Download GoogleStyle.xml and edit the following settings:

<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="1" />
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>

Then in vscode settings.json, set

"java.format.settings.url": "<local path to java-google-style.xml>",

You can keep the formatting style that you want instead of parameters being formatted to one line: enter image description here

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22
  • Not exactly the desired effect but this is a step in the right direction. We've got this interesting codestyle at work which isn't really standard practice it seems, and hence is not supported by tooling. Thanks for the thorough answer. – Albert Scholtz Mar 02 '21 at 09:40
  • @theBushman. You're welcome. If there's any solution update about this question, i'll let u know. – Molly Wang-MSFT Mar 03 '21 at 01:47
2

This setting helped achieve the desired alignment format.

<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="18"/>

<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="18"/>

<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="18"/>

<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="18"/>

This is taken after changing up the settings in an Eclipse IDE. enter image description here

louis1204
  • 401
  • 1
  • 7
  • 21