Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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]

like image 374
huangzhuohua Avatar asked Aug 09 '18 12:08

huangzhuohua


1 Answers

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.

like image 84
thatjeffsmith Avatar answered Nov 15 '22 03:11

thatjeffsmith