次の例では、私は期待してインデントを追加するフォーマッタと、コードのクリーンアップを設定することが日食(または拡張)できます:括弧間に複数の行をインデントするようにEclipseフォーマッタを設定できますか?
public static void main(String[] args) {
String[] numbers = new String[] {
"one",
"two",
"three",
"four",
};
new MessageFormat("{0} {1} {2} {3}").format(
"this is string one",
"this is string two",
"this is string three"
);
System.out.println(
new MessageFormat("{0} {1} {2} {3}").format(
new String[]{
"this is string zero",
"this is string one",
"this is string two",
"this is string three"
}
)
);
}
私は私が見つけることができるすべての設定をいじってきました。 「行に参加することはありません」オプションでは、完全にコードを解体からそれを続け、それでもインデントはすべて取り除かれ、コードは次のように出てくる:
String[] numbers = new String[] {
"one",
"two",
"three",
"four",
};
new MessageFormat("{0} {1} {2} {3}").format(
"this is string one",
"this is string two",
"this is string three"
);
System.out.println(
new MessageFormat("{0} {1} {2} {3}").format(
new String[] {
"this is string zero",
"this is string one",
"this is string two",
"this is string three"
}
)
);
は、私のようなブロックの周りの書式オフにする機能を発見しましたこの:
周りのまともな仕事である
// @formatter:off
String[] numbers = new String[] {
"one",
"two",
"three",
"four",
};
// @formatter:on
、私のコードは、彼らが散らばってしまい、コードのクリーンアップの「正しいインデント」の部分は、ディレクティブを無視して、とにかくインデントを台無しにすることを除いて。
編集:「行折り返し」 - >「折り返し行のデフォルトのインデント」および「配列のデフォルトのインデントが初期化」の設定が見つかり、「0」ではなく「1」に設定しました。これは、配列初期化子のためのより良いですが、それでも開口部に一致するようにインデント決算parethesisは、私がそれを望むようにかっこません。
public static void main(String[] args) {
String[] numbers = new String[] {
"one",
"two",
"three",
"four",
};
new MessageFormat("{0} {1} {2} {3}").format(
"this is string one",
"this is string two",
"this is string three"
);
System.out.println(
new MessageFormat("{0} {1} {2} {3}").format(
new String[] {
"this is string zero",
"this is string one",
"this is string two",
"this is string three"
}
)
);
}
はい、各構成要素のインデントを変更します。それぞれに3-4のオプションがあります。あなたが何かを平坦化しているなら、かなり壊れた設定があります。デフォルトでは、私はあなたが望むフォーマットを得ると思います。 –