Condensed close curly braces at end of Java code blocks in Eclipse

I

Ion Freeman

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
 
D

Donkey Hottie

Ion Freeman said:
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.
 
R

Robert Klemme

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
 
M

Mark Rafn

Ion Freeman said:
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.
 
T

Tom Anderson

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
 
S

Seamus MacRae

Ion said:
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.
 
A

Arne Vajhøj

Ion said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top