Reputation: 20873
How can I prevent Eclipse from removing whitespace within a line?
Example:
final Map<String, String> capitalOf = new HashMap<String, String>();
capitalOf.put("France", "Paris");
capitalOf.put("Italy", "Rom");
capitalOf.put("Switzerland", "Bern");
gets becomes after calling 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");
Upvotes: 0
Views: 59
Reputation: 6204
You can edit the behavior of the Java Formatter in the white space section of the Preferences (Java - Code Style - Formatter).
In your case you will have to rely on the formatter tags to turn off the formatting of your code:
@formatter:off
capitalOf.put("France", "Paris");
capitalOf.put("Italy", "Rom");
capitalOf.put("Switzerland", "Bern");
@formatter:on
For this to work, the off/on tags have to be enabled as shown below:
Upvotes: 1