【问题标题】:Eclipse - Wrapped lines' indentation appears & disappears each time I saveEclipse - 每次保存时,换行的缩进都会出现和消失
【发布时间】:2014-04-23 11:08:02
【问题描述】:

每次单击Save 时,整个文件的格式都会在这两种格式之间交替:

this.getObject()
        .method()
        .method();
this.method(arg1, arg2,
        arg3, arg4);

this.getObject()
.method()
.method();
this.method(arg1, arg2,
arg3, arg4);

我希望它坚持第一种格式。

【问题讨论】:

    标签: java eclipse coding-style formatter eclipse-jdt


    【解决方案1】:

    我当前的 Eclipse 配置也有同样的问题。我认为这是一个 Eclipse 错误。

    我的猜测是问题与选项有些相关:

    Java 代码风格 -> 清理 -> 代码组织 -> 正确缩进

    发生冲突

    Java 代码风格 -> 清理 -> 代码组织 -> 格式化源代码

    它应该已经根据格式化程序设置修复了缩进。

    我在Java Code Style -> CleanupJava Editor -> Save Actions -> Additional Actions -> Configure... 中都禁用了Correct indentation 选项,问题似乎消失了。

    【讨论】:

    • 这对我没有帮助。知道Check: Remove trailing whitespace / Radio: All lines 是否是罪魁祸首
    【解决方案2】:

    您可能需要从

    更正现有的代码格式
    Eclipse preferences > Java > code style > Formatter
    

    或者如果当前的格式化程序搞砸了,你可以在保存过程中取消选中自动格式化选项

    Eclipse preferences > Java > Editor > Save Actions - UnCheck Format source code.
    

    【讨论】:

    • 我想要格式化程序。格式化后,没有理由每次我重新保存完全相同的文件时都会更改它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-18
    • 1970-01-01
    • 2019-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多