Quantcast
Channel: formatter | ThatJeffSmith
Viewing all articles
Browse latest Browse all 19

Preserving Line Breaks in Oracle SQL Developer 4

$
0
0

Ugly code, we all write it.

I don’t mean bad code either, just hard to read code. Developers who haven’t figured out how to use the TAB and ENTER keys – what’s up with that? — and why is Jeff talking to himself in his Seinfeld voice again?

So one of the features in SQL Developer is the Formatter. With a simple right-click (or a Ctrl+F7), you can take your code from ugly to beautiful, mostly.

But I Hate How I Lose My New Lines!

That was something I heard several times over while taking your feedback on our formatter.

You put in a bunch of newlines to make your code more readable, you go to format, and you lose all that work.

No good.

Pre-Formatting

My code before I format.

My code before I format.

Post-Formatting in 3.2

So I’m going to format my code now…voila! What you see below is my code in the File History viewer. This is why people were getting upset, I’m guessing.

Side by Side, Before and After Format using v3.2 Formatter

Side by Side, Before and After Format using v3.2 Formatter

Here’s the control you have over new lines, adding or removing, in version 3.2:

Do you want more newlines or less newlines?

Do you want more newlines or less newlines?

So either you can have lines added here and there, or you can allow us to collapse any extra new lines.

What you asked for, is an option that says, LEAVE MY BLANK LINES ALONE!

The Options for Version 4.0

Preserve Existing!

Preserve Existing!

So now you have 3 options:

  1. Minimize – remove blank lines as possible
  2. Add Extra – throw new lines in for readability
  3. Preserve Existing – no touch existing blank lines!

So with ‘Preserve Existing’ selected, when I do a format in 4.0, here’s what I’m left with. Again, showing the File History compare widget to demonstrate the before and after.

Woohoo!

Woohoo!

We’ve implemented a few formatter tweaks in this release. Be sure to check out our release notes once the product if officially launched to get more info.

Our Formatter developer (he does MUCH more than this, but he gets to handle all of the formatting fun), Turloch, has started a blog post going into more detail on documenting each of the formatter preferences. I believe it’s a work in progress, but you can bet I’ll be relying on it as a reference going forward.


Viewing all articles
Browse latest Browse all 19

Trending Articles