20

Is there a way to generate a SELECT * FROM template in SQL editor by a certain keyboard shortcut in PL/SQL Developer or another similar tool ?

It would be great to save the time needed to write this repetitive statement with such keyboard shortcut.

TLama
  • 75,147
  • 17
  • 214
  • 392
user2850769
  • 321
  • 1
  • 2
  • 5

9 Answers9

45

We can set up some shortcuts for there regularly used words. For example, we can type s, and pressing the space bar, the letter s will be replaced with SELECT and another example, type sf and hit space bar, it will be replaced with select * from. This really saves a lot of time instead of writing these statements again and again.

To do this: Go to Tools -> Preferences -> Editor -> autoreplace -> Click Edit

In the pop up box, type the following definitions:

s = SELECT
f = FROM
w = WHERE
o = ORDER BY
d = DELETE
sf = SELECT * FROM
df = DELETE FROM
SC = SELECT COUNT (*) FROM

and save the AutoReplace.txt file, wherever you want. Click Apply and go ahead trying to use them.

If you want to edit/add/delete some of the above defined shortcuts, perform the same procedure from the Tools menu until clicking the Apply button.

Hope this helps you, as it did to me.

Stonz2
  • 6,306
  • 4
  • 44
  • 64
  • 1
    Whatever works for you - however I would recommend making the shortcuts at least two letters long, otherwise every time you type `from departments d` it'll become `from departments delete`. I use `s*` and `sc*` a lot, as well as things like "seelct" and "freom" for automatic typo correction. – William Robertson Jan 26 '16 at 14:28
  • Is this working on SQL SERVER 2016? I can't fine the auto replace. – Buchiman Jul 24 '19 at 03:17
  • @Buchiman see Tools > Preferences > Database > SQL Editor Code templates. – Ashok Chhetri Dec 14 '20 at 09:38
5

You can set shortcuts for all things used in PL/SQL Developer but not for syntax.

For syntax you can use custom Templates. PL/SQL Developer has great user guide so you will find that in Templates section.

If you ant to use autocomplete you can set shortuc for it in Tools -> Preferences... Section: User interface -> Key Configuration and next you must find Tools/Code Assistant and set keys whatever you want.

I had it in version 10 of PL/SQL Developer.

4

Actually, there is such a way in PL/SQL Developer using AutoReplace. If you go to Tools | Preferences | Editor configuration, you can add your replacement key/text in the AutoReplace.

Click on Edit... and it will prompt you to add a replacement text using the format:

<word> = <replacement[.tpl]>

You can then use this in one of two different ways.

  • Include the replacement text in the editor

Example: s*=SELECT * FROM

  • Use a template to define the replacement text

Example: join*=sql_join.tpl (where the file is located inside of the templates directory defined Tools | Preferences | Directories (see the Templates directory)

Generally template file can give you a multi-line replacement and is useful for more complicated replacements. The example you provide however would be most generally handled more easily by including the replacement text itself in the editor.

  • 1
    I cannot get the autoreplace to work. Whenever I list a pair with a named file it just replaces the text with the path to the file, not the template itself. – Lloyd Jan 23 '15 at 22:55
  • 1
    @Lloyd put the template on the roaming folder (C:\Users\\AppData\Roaming\PLSQL Developer...>) – Manuel Romeiro Jul 01 '20 at 17:31
3

In SQL Developer you can create "snippets" that you can drag into code but there's not a way that I know of to assign keyboard shortcuts to them.

In Toad you can also create snippets and then assing a short name (e.g. "SSF") that can be expanded with Ctrl-Space.

D Stanley
  • 149,601
  • 11
  • 178
  • 240
3

For SQL Developer 18: Preferences → Database → SQL Editor Code Templates.

For using press Ctrl+Space after typing ssf in worksheet.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Mark S
  • 31
  • 2
2

One can do it by recording a macro and giving it a keyboard shortcut. To record the macro, F11 then type in the SQL window "SELECT * FROM" then F11. Then go to the Macro library to give it a description/name. Then hopefully in the list of items of Tools | Preference | Key configuration, you can find an item called Macro / the_description_you_typed and assign it a shortcut.

whiz
  • 21
  • 2
1

Yes!! by creating a template.

Goto Tools>>Preferences>>Database>>SQL Editor Code Templates

Add Id as 'ssf' and Template as 'SELECT * FROM'

Then on editor type ssf , then Ctrl+Space

0

You can create a macro for the functionality you're asking for.

To do this, use the record macro function (default F11) then type SELECT * FROM in your editor.

After this, you can assign your macros to a hotkey, under Preferences>>Key Configuration. I assigned the select * from to Ctrl+W and delete from to Ctrl+D (depends on your preferences).

Note however that I'm unsure whether you have access to these features.

Hope this helps

Rabih Melko
  • 68
  • 10
0

Finding the HotKeys and what they are for --

There is a place to find what all the shortcut hotkeys are, and what they are configured to do. Plus, you can change them to make them your own.

On your IDE, if you are using PL/SQL v.12.0.7, you can find hotkeys details by going to [Configure] Tab/[Preferences]/ Key Configuration - where you can find many hotkey items on the list.

PL-SQL-Developer-Hotkeys.jpg

Jenna Leaf
  • 2,255
  • 21
  • 29