Updated 17 April, 2020: This feature now supports AutoReplace
Oracle Docs just underwent a facelift, and I was testing to make sure that the code insight feature in SQL Developer was still able to pick out our code samples. Good news, it still works!
But, I was getting distracted by a bit of code that LOOKED like it was DOCS related, yet wasn’t…
So if it’s not coming from the docs, where is it coming from? Well, I knew where, but I activated it just to make sure.
Wait, that one bit of text is highlighted, what happens if I start typing?
Yes, You Can Define the Curpos in a SQL Editor Code Template!
I’m using an exclamation point because I’m excited. I’m excited because I’ve proven again that I’m an idiot. I’ve been asked this question a dozen times or so and I’ve failed to realize how the answer was staring at me in the face.
So after seeing the answer in the create procedure template, I’ve used it to update my SELECT * FROM template:
And to prove that it works as the people have been asking for the past many years:
Yes, I hate SELECT *.
So let’s fix that.
The ‘magic’ keyboard sequence
Ctrl+Spacebar – the same key sequence to get the code insight assistance will replace the template with the code. Thanks to Nate for bringing it to my attention that I left this key bit out…
But Jeff, I don’t want to ‘invoke’ this, it should JUST happen automatically
You can enable this behavior. So as a template name is recognized, if you hit tab, spacebar, or a newline, the editor will automatically replace your text.