【发布时间】:2016-07-27 06:19:46
【问题描述】:
我正在使用 Eclipse Luna,我想对齐/缩进多行字符串文字,以便每一行从同一列开始。但我无法说服 Eclipse 在代码样式格式化程序中执行此操作。
这是它当前的格式:
final String string1 =
"abc" +
"def" +
"ghi";
System.out.println(
"abc" +
"def" +
"ghi");
System.out.println("" + // an ugly workaround
"abc" +
"def" +
"ghi");
method("xyz",
"" + // Especially ugly in this case
"abc" +
"def" +
"ghi");
但这是我真正想要的:
final String string2 =
"abc" +
"def" +
"ghi";
System.out.println(
"abc" +
"def" +
"ghi");
// Or something like this would be fine too
final String string3 =
"abc"
+ "def"
+ "ghi";
System.out.println(
"abc"
+ "def"
+ "ghi");
这似乎是一种简单而理想的格式。只需在同一列上开始分解线的每个部分。但我无法在任何地方找到一种方法。
【问题讨论】:
-
你试过这个答案吗? stackoverflow.com/a/23348066/5119765
标签: eclipse formatting alignment indentation code-formatting