【问题标题】:Vscode eclipse formatter setting to align method parametersVscode eclipse格式化程序设置对齐方法参数
【发布时间】:2021-05-31 16:40:51
【问题描述】:

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

当前

    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
    }

【问题讨论】:

    标签: java visual-studio-code vscode-settings eclipse-formatter


    【解决方案1】:

    关于Java格式化,可以参考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>",
    

    您可以保留所需的格式样式,而不是将参数格式化为一行:

    【讨论】:

    • 不完全是想要的效果,但这是朝着正确方向迈出的一步。我们在工作中使用了这种有趣的代码样式,它看起来并不是真正的标准做法,因此不受工具的支持。感谢您的详尽回答。
    • @theBushman。不客气。如果有关于这个问题的任何解决方案更新,我会告诉你。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-13
    • 2014-09-08
    • 1970-01-01
    • 2011-01-07
    • 2020-12-02
    • 1970-01-01
    相关资源
    最近更新 更多