繁体   English   中英

vscode eclipse formatter设置对齐方法参数

[英]Vscode eclipse formatter setting to align method parameters

vscode中哪个eclipse-formatter设置会完成下面的格式化,特别关注参数alignment?

当前的

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

想要的

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

此设置有助于实现所需的 alignment 格式。

<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"/>

这是在更改 Eclipse IDE 中的设置后拍摄的。 在此处输入图像描述

关于 Java Formatting,可以参考Formatting and Linting

下载GoogleStyle.xml并编辑以下设置:

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

然后在 vscode settings.json 中,设置

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

您可以保留所需的格式样式,而不是将参数格式化为一行: 在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM