Not to start a religious war, but white space in your code can cause havoc when you’re doing code compares and versioning.

Some folks like tabs, others prefer to control how their code looks regardless of the editor’s tab display options.

From what I can tell, SQL Developer’s code editors won’t even let you insert a tab into them – they auto-convert a tab into 2 spaces.

But, if you’ve pasted tabbed code in, they’ll remain.

Tip: Set your code editor display preferences to show whitespace characters – that way you can see tabs and spaces CLEARLY.

This code has tabs...
This code has tabs…

vs…

...and this code has spaces
…and this code has spaces

The Formatter Can Tabs to Spaces When Indenting

Go from tabs to spaces, and just how many spaces?
Go from tabs to spaces, and just how many spaces?

If this post seems familiar, it’s because I’ve talked about this before. But we’re changing the formatter for version 4.2, and @oraclenerd reminded me in his awfully nice review of SQLDev that some folks rely on this feature a LOT. It still words as expected in this regard for the next version ๐Ÿ™‚

One Last Tip

If you really, really hate tabs – to the point that you do cool stuff like this:

Rejecting code check-ins b/c your code has TABS = hard core :)
Rejecting code check-ins b/c your code has TABS = hard core ๐Ÿ™‚

Our team has a similar rule, and file checked-in w/fewer than 10% of the code being comments is REJECTED.

Anyways, if you do stuff like this, and forget to format your code…when we generate SQL code for database objects, if you have the Pretty Print option enabled in the preferences, it may insert TABs.

Version v4.2 MAY just feed generated SQL and PL/SQL through our formatter...
Version v4.2 MAY just feed generated SQL and PL/SQL through our formatter…

When is v4.2 coming?

Soon. I’m only teasing it because it’s on the horizon. Stay tuned ๐Ÿ™‚

thatjeffsmith
Author

I'm a Master Product Manager at Oracle for Oracle SQL Developer. My mission is to help you and your company be more efficient with our database tools.

2 Comments

  1. Doctor Evil has an evil point!

    That is a drawback to plain-text editing … one cannot see tab chars.
    I am always horrified with people’s Microsoft docs … the amount of abuse formatting takes … and the mis-creation of forms! Shocking.

  2. Tabs should be converted to 3 1/2 spaces for sql scripts and 2 1/3 spaces for packages, depending on the font. ๐Ÿ™‚

Write A Comment