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
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.
Here’s the control you have over new lines, adding or removing, in version 3.2:
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
So now you have 3 options:
- Minimize – remove blank lines as possible
- Add Extra – throw new lines in for readability
- 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.
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.