每次单击Save
时,整个文件的格式在这两种格式之间交替:
this.getObject()
.method()
.method();
this.method(arg1, arg2,
arg3, arg4);
和
this.getObject()
.method()
.method();
this.method(arg1, arg2,
arg3, arg4);
我希望它坚持第一种格式。
我当前的Eclipse配置也有同样的问题。我认为这是一个Eclipse错误。
我的猜测是,这个问题在某种程度上与选项有关:
Java代码样式->清理->代码组织->正确缩进
与发生冲突
Java代码样式->清理->代码组织->格式化源代码
它应该已经根据格式化程序设置修复了缩进。
我禁用了Java Code Style -> Cleanup
和Java Editor -> Save Actions -> Additional Actions -> Configure...
中的选项Correct indentation
,问题似乎消失了。
您可能需要从中更正现有的代码格式
Eclipse preferences > Java > code style > Formatter
或者,如果当前的格式化程序出现问题,您可以在使用保存时取消选中自动格式化选项
Eclipse preferences > Java > Editor > Save Actions - UnCheck Format source code.