user2884789
user2884789

Reputation: 533

Customizing the code formatting style in Eclipse IDE

I use Eclipse IDE to format my code, i.e ctrl+shift+f

Here is what it's doing:

int[] array = 
        { 1, 2, 7, 1 };

Here is what I wish it did:

int[] array = { 1, 2, 7, 1 };

How can I stop the Eclipse formatter from putting a new line after equals when initalizing array ?

Upvotes: 2

Views: 182

Answers (1)

johnnykp
johnnykp

Reputation: 21

Hope this http://www.wikihow.com/Change-the-Default-Format-Settings-in-Eclipse can help you, take a look

Try steps below in your eclipse:

  • Window Menu -> Preferences;
  • Java -> Code Style -> Formatter -> Edit your active profile;
  • Go to Line Wrapping Tab;
  • Search for "Expressions -> Array Initializers;
  • Change Settings for array initializers, Line wrapping policy: "Do not wrap". OR
  • Go to "Braces" Tab;
  • Check if array initializer option is "Same Line".

Upvotes: 2

Related Questions