Skip to main content


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: 637
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: public static <T> @NonNull T @NonNull [] arrayElementsAreNonNull( @Nullable T @Nullable[] val
Next Topic:[Java8] Wrong compilation error reported?
Goto Forum:
  


Current Time: Sat Oct 12 17:06:41 GMT 2024

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

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

Back to the top