Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Java: Multidimensional Array Initialization Formatting(Formatter doesn't play nice)
Java: Multidimensional Array Initialization Formatting [message #1065095] Mon, 24 June 2013 06:57 Go to next message
Daniel S is currently offline Daniel S
Messages: 2
Registered: June 2013
Junior Member
Hello, hopefully this is the correct section for this (it does appear to be for general questions)

I'm having trouble getting the formatter to format 2d (and above) arrays the way I want them to be..

int firstarray[][] =
{
    { 5, 6, 7, 8 },
    { 9, 10, 11, 12 },
};


It might be a bit silly to be so particular, but despite fiddling with all the settings I could find for array initializers (braces, white space, new lines and line wrapping) I haven't been able to get it so they're indented and on separate lines like that.

I'd be much obliged if anyone had any ideas. Smile

[Updated on: Mon, 24 June 2013 10:16]

Report message to a moderator

Re: Multidimensional Array Initialization Formatting [message #1065144 is a reply to message #1065095] Mon, 24 June 2013 09:39 Go to previous messageGo to next message
Russell Bateman is currently offline Russell Bateman
Messages: 3125
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 6/24/2013 6:10 AM, Daniel S wrote:
> Hello, hopefully this is the correct section for this (it does appear to
> be for general questions)
>
> I'm having trouble getting the formatter to format 2d (and above) arrays
> the way I want them to be..
>
>
> int firstarray[][] =
> {
> { 5, 6, 7, 8 },
> { 9, 10, 11, 12 },
> };
>
> It might be a bit silly to be so particular, but despite fiddling with
> all the settings I could find for array initializers (braces, white
> space, new lines and line wrapping) I haven't been able to get it so
> they're indented and on separate lines like that.
> I'd be much obliged if anyone had any ideas. :)

Actually, sorry, you're way off. Yours is a question for a general
programming forum. This forum answers questions about setting up and
using the Eclipse IDE. I might suggest stackoverflow.com or a
programming language-specific forum.
Re: Multidimensional Array Initialization Formatting [message #1065159 is a reply to message #1065144] Mon, 24 June 2013 10:14 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2235
Registered: July 2009
Senior Member
I suspect Russell misread that, but first off it helps to identify which language you're working with. It's still possible that this is something a formatter is just not able to do.

---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: Multidimensional Array Initialization Formatting [message #1065160 is a reply to message #1065144] Mon, 24 June 2013 10:14 Go to previous messageGo to next message
Daniel S is currently offline Daniel S
Messages: 2
Registered: June 2013
Junior Member
Russell Bateman wrote on Mon, 24 June 2013 09:39

Actually, sorry, you're way off. Yours is a question for a general
programming forum. This forum answers questions about setting up and
using the Eclipse IDE. I might suggest stackoverflow.com or a
programming language-specific forum.


Well, my question is specific to using Eclipse. I'm asking about how to setup Eclipse's formatter in a particular way. How is that not about using Eclipse?

Nitin Dahyabhai wrote on Mon, 24 June 2013 10:14
I suspect Russell misread that, but first off it helps to identify which language you're working with. It's still possible that this is something a formatter is just not able to do.


Java, sorry. Thought I said that.

[Updated on: Mon, 24 June 2013 10:17]

Report message to a moderator

Re: Multidimensional Array Initialization Formatting [message #1065166 is a reply to message #1065160] Mon, 24 June 2013 10:44 Go to previous messageGo to next message
Russell Bateman is currently offline Russell Bateman
Messages: 3125
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 6/24/2013 8:14 AM, Daniel S wrote:
> Well, my question is specific to using eclipse. I'm asking about how to
> setup Eclipse's formatter in a particular way. How is that not about
> using Eclipse?

Ah, I did misread this.

Very sorry.

So, as Nitin pointed out, it's crucial to know which language (since
your code snippet is ambiguous--could be C/C++ or Java). And it might
not be something that can be generalized or doable. However...

Eclipse is good at handling this, but let me speak to Java.

If you don't like the default handling the Eclipse Java editor imposes,
you're perfectly free to modify it yourself. You do this via Window ->
Preference -> Java -> Code Style -> Formatter where, playing around with
the interface a bit, you'll discover just how you can change it.

Later, satisfied with your changes, you can save them to a file that can
be shared with friends, between Eclipse installations, etc. via the
Export (then Import) buttons in that same dialog.

Note that any of the myriad default Eclipse settings you don't change
will just be as if part of your private format settings you save.

How this works for C/C++ I don't know. I did C/C++ for 25+ years, but
never in Eclipse. I sought refuge from the dark side in Java years ago
and haven't strayed much since. :-)

Hope this helps.
Re: Multidimensional Array Initialization Formatting [message #1065366 is a reply to message #1065166] Tue, 25 June 2013 09:02 Go to previous message
Claudio Heeg is currently offline Claudio Heeg
Messages: 75
Registered: April 2013
Member
As Nitin indicated, it's very doubtful that that is at all possible with the built-in formatter.
Link [1], which I reckon lists every option regarding this (i.e. the stuff the XML export contains), doesn't offer anything regarding multidimensional arrays, but should you solve this problem, I'd be quite interested in how such a thing could be modified.

--
[1] http://publib.boulder.ibm.com/infocenter/rsahelp/v7r0m0/index.jsp?topic=/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.html
Previous Topic:Birt - Dataset picks wrong Database
Next Topic:Programmatically close file in text editor?
Goto Forum:
  


Current Time: Sat Jul 26 03:11:31 EDT 2014

Powered by FUDForum. Page generated in 0.03232 seconds