XYZABC
XYZABC

Reputation: 165

How to set Oracle SQL Developer automatically wrap long SQL statements

In Oracle SQL Developer, some queries are too long to show in one line, so I must use the scroll bar to see the hidden text on the right side.

How can I make Oracle SQL Developer to automatically wrap long query onto a new line?

My query]

Upvotes: 10

Views: 27962

Answers (3)

Punnerud
Punnerud

Reputation: 8021

Thanks to thatjeffsmith

CTRL+F7

Will convert from one-line to formated code. Not a direct answer to the question, but a better solution to my similar question/problem.

Upvotes: 6

Pablito
Pablito

Reputation: 197

The previous answer seem to be out-of-date. For PL/SQL Developer v. 12.0.7.1837 you can go to

Configure > Preferences > User Interface - Editor > Tabs & Wrapping - Wrap lines.

enter image description here

Upvotes: -1

thatjeffsmith
thatjeffsmith

Reputation: 22427

There is no 'auto transform my code', but we do have the formatter.

The formatter has rules. There is a rule which will control the max length of a line of code.

Set the Max char line width preference in the formatter.

Then format your code (ctrl+F7)

enter image description here

It's not absolute, however.

Below is a screenshot of the setting set to 45, also with the visible line gutter set to also 45 (and red), with some formatted code.

Note I've also told the formatter NOT to insert carriage returns before or after commas in a SELECT or FROM.

enter image description here

We don't cut the text off, mid word...instead, we force a line break at the next whole word. What I suggest instead is investigate the preferences around line breaks in general - of which there are MANY.

As you tweak the preferences, you can see your sample code format in real time, so you know what the true effect is.

Upvotes: 7

Related Questions