Skip to main content



      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 11:23 Go to next message
Eclipse UserFriend
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 12:01 Go to previous message
Eclipse UserFriend
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,
Previous Topic: public static <T> @NonNull T @NonNull [] arrayElementsAreNonNull( @Nullable T @Nullable[] val
Next Topic:[Java8] Wrong compilation error reported?
Goto Forum:
  


Current Time: Sun Jun 15 02:49:11 EDT 2025

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

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

Back to the top