Quantcast
Viewing all articles
Browse latest Browse all 19

SQL Developer Formatter: Left Aligning Columns in a SELECT

Question:

 I can’t figure out how to make a column list align like this
(underscore = space):

_SELECT_column1
______,_column2
______,_column3
______,_column4
___FROM_table

The closest result that the formatter produces is:

_SELECT_column1,
__column2,
__column3,
__column4
___FROM table

where all column names start at text position 3...

My answer isn’t going to be perfect, but it’s going to get the questioner, and you, very close to what you’re looking for.

Set These Formatter Preferences

Image may be NSFW.
Clik here to view.
column_indent1

One comma per line. Line break before a comma. No line break after a comma.

Image may be NSFW.
Clik here to view.
align_columns2

Align on commas.

Image may be NSFW.
Clik here to view.
align_columns3

Indent 7 spaces.

Before Format

After Format

Is this perfect?

No. You’ll notice we’re hard coding the indentation point. So if your SELECT starts with a comment or hint, it won’t align exactly. But again, I’m trying to save you time based on what we have in the formatter today. Tomorrow, it would be ideal for the parser to supply the formatter the exact column position for alignment…stay tuned.

In version 4.1, you’ll have a bit easier time mass-tabbing columns in your text as well…

Image may be NSFW.
Clik here to view.
Multi-cursor support in version 4.1 #SneakPeek

Multi-cursor support in version 4.1 #SneakPeek


Viewing all articles
Browse latest Browse all 19

Trending Articles