Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » What formatter option can I change to stop my arrays being formatted onto one line(What formatter option can I change to stop my arrays being formatted onto one line)
icon9.gif  What formatter option can I change to stop my arrays being formatted onto one line [message #1748386] Tue, 22 November 2016 16:23 Go to next message
James Yeoman is currently offline James YeomanFriend
Messages: 5
Registered: November 2016
Junior Member
I am working on some OpenGL but it is extremely annoying that, rather than just putting

float [] verts = {
    -0.5f , -0.5f ,
     0.0f ,  0.5f ,
    -0.5f ,  0.5f
};


for the vertices of a triangle, I have to use

//@formatter:off
float [] verts = {
    -0.5f , -0.5f ,
     0.0f ,  0.5f ,
    -0.5f ,  0.5f
};
//@formatter:on


which, not only looks horrible, also is inefficient and requires moving the opening and closing formatter tags if I later decide to put another array in there. How do I go about making the formatter accept the first format rather than the "wrapped onto one line" format?
Re: What formatter option can I change to stop my arrays being formatted onto one line [message #1748505 is a reply to message #1748386] Wed, 23 November 2016 17:01 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 634
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hello James,

you can modify Eclipse Java Formatter:
- Window -> Preferences -> Java -> Code Style -> Formatter
- Edit...
- Line Wrapping tab
- in the tree, select Expressions -> Array initializers
- in the "Settings for array initializers" group, use "Wrap all elements, every element on the same line" (or another one which is matching what you want exactly)

regards,


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Previous Topic:Java Type mismatch error on upgrade Eclipse Mars to Eclipse Neon
Next Topic:help
Goto Forum:
  


Current Time: Mon Nov 20 17:44:47 GMT 2017

Powered by FUDForum. Page generated in 0.01590 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software