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
}
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.
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.