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  |
Eclipse User |
|
|
|
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.
[Updated on: Mon, 24 June 2013 10:16] by Moderator
|
|
|
Re: Multidimensional Array Initialization Formatting [message #1065144 is a reply to message #1065095] |
Mon, 24 June 2013 09:39   |
Eclipse User |
|
|
|
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 #1065166 is a reply to message #1065160] |
Mon, 24 June 2013 10:44   |
Eclipse User |
|
|
|
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.
|
|
| |
Goto Forum:
Current Time: Tue Jul 22 11:46:34 EDT 2025
Powered by FUDForum. Page generated in 0.09126 seconds
|