Is there a keyboard shortcut for writing “SELECT * FROM” template?

对着背影说爱祢 提交于 2019-11-29 02:12:14

问题


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.


回答1:


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.




回答2:


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.




回答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.




回答4:


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.




回答5:


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.




回答6:


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

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




回答7:


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




回答8:


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




回答9:


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.



来源:https://stackoverflow.com/questions/21172032/is-there-a-keyboard-shortcut-for-writing-select-from-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!