Rajat Khanna
Rajat Khanna

Reputation: 15

How to get eclipse code formatter to wrap assignment statements onwards = operator

I'm using eclipse code formatter, and I've set maximum line length to 120. If an assignment statement is longer than 120 characters, for example

private Map<Instruction, LocalRegisterAssignmentInformation> instructionRegisterMap = new IdentityHashMap<Instruction, LocalRegisterAssignmentInformation>();

I would like the formatter to wrap this line and make the statement look like this:

private Map<Instruction, LocalRegisterAssignmentInformation> instructionRegisterMap
  = new IdentityHashMap<Instruction, LocalRegisterAssignmentInformation>();

But the formatter doesn't seem to wrap it. I tried finding relevant options in the eclipse formatter profile settings, but couldn't find any.

Upvotes: 1

Views: 435

Answers (1)

howlger
howlger

Reputation: 34155

Edit your Java formatter profile as follows:

  1. In Line Wrapping select Expressions > Assignments
  2. Set Line wrapping policy to Wrap where necessary
  3. Check the checkbox Wrap before operator

Upvotes: 1

Related Questions