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

Case Closed: lower, InitCAP, UPPER, And Stuff

$
0
0

Best practice for code readability dictates that your keywords should always be in: insert your preferred style here __________.

Here’s a Twitter poll I’m running if you want to personally weigh in:


So even if we can’t all agree on what’s best, we can all agree that our tools should help us get the code we inherit or write in the format/shape that WE want.

Thankfully when it comes to Oracle SQL and PL/SQL, SQL Developer gives you a lot of options.

Format a Bunch of Code All At Once

So you open a file, or paste in a 1,000 line query. You want some help to make it a bit easier to read. One of the things the formatter offers is the ability to change the case of certain things.

The formatter won't step into your code comments.

The formatter won’t step into your code comments.

I know that’s a little hard to see, so here’s a closer look.

formatter_case2

You’ll notice the number of options here isn’t as robust as the Completion Insight bits I talk about next. We’re updating the formatter for version 4.2, and we’ll try to get you even more flexibility when it comes to the case of your code.

Format Code as You Type It

So this will set the case of your identifiers, you’ll see it immediately when you pull up a list of objects using the ctrl+space keyboard shortcut, but you’ll ALSO see it after you go to the next line of your code – you’ll see the case of your keywords and identifiers change based on this code editor preference.

lower_case_columns

You CAN disable the format as you type, so it would only apply if you're using the insight pop-ups.

You CAN disable the format as you type, so it would only apply if you’re using the insight pop-ups.

Brute Force It

Of course the editor itself also lets you make everything UPPER, lower, or InitCaps.

Select your text, and go.

You can toggle through the 3 styles, or you can go straight to UPPER or lower.

Note that the first two editor operations aren't mapped to keyboard shortcuts, so you'll have to set them if you want to use them.

Note that the first two editor operations aren’t mapped to keyboard shortcuts, so you’ll have to set them if you want to use them.


Viewing all articles
Browse latest Browse all 19

Trending Articles