如何防止Eclipse删除行内的空格?
示例:
final Map<String, String> capitalOf = new HashMap<String, String>();
capitalOf.put("France", "Paris");
capitalOf.put("Italy", "Rom");
capitalOf.put("Switzerland", "Bern");
调用Format
后变为( Ctrl - Shift - F )
final Map<String, String> capitalOf = new HashMap<String, String>();
capitalOf.put("France", "Paris");
capitalOf.put("Italy", "Rom");
capitalOf.put("Switzerland", "Bern");
答案 0 :(得分:1)
您可以在首选项(Java代码样式 - 格式化程序)的空白区域中编辑Java Formatter的行为。
在您的情况下,您将不得不依赖格式化程序标签来关闭代码的格式:
@formatter:off
capitalOf.put("France", "Paris");
capitalOf.put("Italy", "Rom");
capitalOf.put("Switzerland", "Bern");
@formatter:on
为此,必须启用off / on标签,如下所示: