|
|||
|
Hi!
Frankly, most of the code I write is for publication somewhere, so I try to keep everything within eighty columns and use vertical space efficiently. I'm new to Eclipse, and I'd like to set up this behavior: When a number of braced blocks end together at the end of a method body or class, I'd like to compress them all. So class outer{ class inner{ method body(){ for(){ if(){ finally{ // would have the final line } } } } } } -- visually every block of code is closed, but it's strictly in the opposite order, so that all the closures happen on one line. I'm having some trouble getting Eclipse to do this -- it doesn't seem to be built in and I don't know where to start scripting it. I imagine this is a pretty popular thing to do, so I was hoping there was a snappable way I could get it done. Can someone help me? Ion |
|
|
||||
|
||||
|
|
|
|||
|
"Ion Freeman" <ionfreeman@gmail.com> wrote in message
news:e8b5fac5-953d-45a1-8328-50a6c5c30d71@n8g2000vbb.googlegroups.com > Hi! > Frankly, most of the code I write is for publication > somewhere, so I try to keep everything within eighty > columns and use vertical space efficiently. I'm new to > Eclipse, and I'd like to set up this behavior: When a > number of braced blocks end together at the end of a > method body or class, I'd like to compress them all. So > class outer{ > class inner{ > method body(){ > for(){ > if(){ > finally{ > // would have the final line > } } } } } } > -- visually every block of code is closed, but it's > strictly in the opposite order, so that all the closures > happen on one line. > > I'm having some trouble getting Eclipse to do this -- it > doesn't seem to be built in and I don't know where to > start scripting it. I imagine this is a pretty popular > thing to do, so I was hoping there was a snappable way I > could get it done. > That looks awful. I understand the eighty columns limit, but saving vertical space. Personally, I always put every curly brace on it own line. |
|
|||
|
On Fri, 19 Jun 2009 13:43:19 -0700, Donkey Hottie <donkey@fred.pp.fi>
wrote: > [...] >> I'm having some trouble getting Eclipse to do this -- it >> doesn't seem to be built in and I don't know where to >> start scripting it. I imagine this is a pretty popular >> thing to do, so I was hoping there was a snappable way I >> could get it done. > > That looks awful. I understand the eighty columns limit, but saving > vertical space. Personally, I always put every curly brace on it own > line. Ditto. And even for those that use the "K&R" bracing style, the closing braces have their own line. Actually, I don't have any problem if someone really wants to format their own code that way. If I knew how to convince Eclipse to do the braces that way, I'd be happy to share that information. (But, I don't...sorry). But a) I'd suggest it's not really the best way to publish code (even the "K&R" style was supposedly mainly about conserving space in their book, and they didn't wind up putting a bunch of closing braces on the same line), and b) I'd certainly disagree that this is "a pretty popular thing to do". I also foresee problems getting Eclipse to do it, as unlike other bracing styles, doing it this way would require progressively accounting for previously-existing blocks other than just for indentation, something I think it's likely Eclipse just wasn't build to handle. Pete |
|
|||
|
On 19.06.2009 21:53, Ion Freeman wrote:
> Frankly, most of the code I write is for publication somewhere, so > I try to keep everything within eighty columns and use vertical space > efficiently. I'm new to Eclipse, and I'd like to set up this behavior: > When a number of braced blocks end together at the end of a method > body or class, I'd like to compress them all. So > class outer{ > class inner{ > method body(){ > for(){ > if(){ > finally{ > // would have the final line > } } } } } } > -- visually every block of code is closed, but it's strictly in the > opposite order, so that all the closures happen on one line. > > I'm having some trouble getting Eclipse to do this -- it doesn't seem > to be built in and I don't know where to start scripting it. I imagine > this is a pretty popular thing to do, so I was hoping there was a > snappable way I could get it done. If this happens frequently in your code you should probably rethink your designs - especially how much you stuff into a single method. I have rarely more than three consecutive closing brackets so I would not feel the need to save that much vertical space. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ |
|
|||
|
Ion Freeman <ionfreeman@gmail.com> wrote:
>Hi! > Frankly, most of the code I write is for publication somewhere, so >I try to keep everything within eighty columns and use vertical space >efficiently. I'm down with that. I woudn't want to give up easy editing by myself or others in pursuit of such, though. >body or class, I'd like to compress them all. So >class outer{ > class inner{ > method body(){ > for(){ > if(){ > finally{ > // would have the final line >} } } } } } >-- visually every block of code is closed, but it's strictly in the >opposite order, so that all the closures happen on one line. Eww. I'd object if I ever had to edit the code, but I guess for some publications it'd be ok. >I'm having some trouble getting Eclipse to do this Yeah, it's probably a fairly uncommon formatting preference. My recommendation: use java standards in your editor, including a bit more indenting and spending the vertical space to give ending braces their own line, and then format for publication as needed, based on the needs for that specific use. Print snippets could compress the way you show, online could stay more standard. -- Mark Rafn dagon@dagon.net <http://www.dagon.net/> |
|
|||
|
On Fri, 19 Jun 2009, Ion Freeman wrote:
> Frankly, most of the code I write is for publication somewhere, so > I try to keep everything within eighty columns and use vertical space > efficiently. I'm new to Eclipse, and I'd like to set up this behavior: > When a number of braced blocks end together at the end of a method > body or class, I'd like to compress them all. So > class outer{ > class inner{ > method body(){ > for(){ > if(){ > finally{ > // would have the final line > } } } } } } > -- visually every block of code is closed, but it's strictly in the > opposite order, so that all the closures happen on one line. > > I'm having some trouble getting Eclipse to do this -- it doesn't seem > to be built in and I don't know where to start scripting it. I imagine > this is a pretty popular thing to do, so I was hoping there was a > snappable way I could get it done. Switch to python. tom -- NO REAL THAN YOU ARE -- Ego Leonard, The Zandvoort Man |
|
|||
|
On 20.06.2009 03:28, Tom Anderson wrote:
> On Fri, 19 Jun 2009, Ion Freeman wrote: >> finally{ >> // would have the final line >> } } } } } } >> -- visually every block of code is closed, but it's strictly in the >> opposite order, so that all the closures happen on one line. > Switch to python. I would getting rid of all the brackets consider to be cheating. :-) Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ |
|
|||
|
Ion Freeman wrote:
> Hi! > Frankly, most of the code I write is for publication somewhere, so > I try to keep everything within eighty columns and use vertical space > efficiently. I'm new to Eclipse, and I'd like to set up this behavior: > When a number of braced blocks end together at the end of a method > body or class, I'd like to compress them all. So > class outer{ > class inner{ > method body(){ > for(){ > if(){ > finally{ > // would have the final line > } } } } } } > -- visually every block of code is closed, but it's strictly in the > opposite order, so that all the closures happen on one line. Eeeuw. How ... Lispy. |
|
|||
|
Ion Freeman wrote:
> Frankly, most of the code I write is for publication somewhere, so > I try to keep everything within eighty columns and use vertical space > efficiently. I'm new to Eclipse, and I'd like to set up this behavior: > When a number of braced blocks end together at the end of a method > body or class, I'd like to compress them all. So > class outer{ > class inner{ > method body(){ > for(){ > if(){ > finally{ > // would have the final line > } } } } } } > -- visually every block of code is closed, but it's strictly in the > opposite order, so that all the closures happen on one line. > > I'm having some trouble getting Eclipse to do this -- it doesn't seem > to be built in and I don't know where to start scripting it. I imagine > this is a pretty popular thing to do, so I was hoping there was a > snappable way I could get it done. If you publish Java code, then you should follow Java coding convention. Arne |
|
|
|
|
![]() |
| Popular Tags in the Forum |
| blocks, braces, close, code, condensed, curly, eclipse, end, java |
| Thread Tools | |
| Display Modes | |
|
|