Configuring the Editor. Quest Software 8.5
Reklama
Reklama
SQL Editor
Tablename Completion
An alternative to using AutoReplace for tablenames is tablename completion.
This works for the logon schema.
Type the first few letters of a table name in your schema, then press <CTRL>.
(period). Toad looks up the list of tables matching the letters. If only one matches, the table name is automatically completed in the editor. If there is more then one match, a popup list appears for you to select the desired table.
For example, if you type dep and press <CTRL>. (period), a list of all tables beginning with dep will popup.
Configuring the Editor
The editor in Toad is used on the SQL Editor and Procedure Editor windows to edit text. The same editor is used in read-only mode on many other windows throughout Toad. This section highlights some of the configurable features. The
Editor Options, which include some of the following options, are discussed in detail in the next section.
User configurable Syntax Color
Highlighting
The editors in the SQL Edit and Procedure Edit windows support flexible syntax highlighting. The highlighting is configurable in the Editor Options window, and the list of reserved words used in each window is also customizable by editing the parser script file. If during a Toad session you have used any window or function that retrieves the tablenames for the active Oracle session, tablenames will be colorized as well.
In order for the editor to support syntax highlighting, the following files distributed with Toad must be located in the Toad\User Files directory:
PLSQLSCR.TXT, for syntax parser scripts
PLSQL.DCI, for code templates
You must have the View | Options | Editors | Load view names from
database at time of first editor window option checked or the Object
Palette must be open.
The View | Options | Procedure Editor| Highlight names of stored
procedures option is checked by default.
75
Toad for Oracle
Editor Parser Scripts
The primary configuration for the editor comes from an editor parser script text file that is loaded at runtime. This file is editable but be VERY careful if you decide to edit this file because NO technical support for altered scripts will be provided.
The particular editor parser script is determined from the language of the object in the editor buffer. In the SQL Edit window editor, this language is always
PLSQL. In the offline text editor and in the Procedure Editor you can also have languages HTML, INI, JAVA, and TEXT. The language is determined from the file extension, e.g., HTML, and is configured in the View| Options | Parser
Scripts page| Language / File Extension Associations grid.
76
SQL Editor
The list of languages and editor parser scripts shipped with Toad is:
LANGUAGE
HTML
INI
JAVA
PL/SQL
TEXT
EDITOR PARSER SCRIPT FILE
HTMLSCR.TXT
INISCR.TXT
JAVASCR.TXT
PLSQLSCR.TXT
TEXTSCR.TXT
All editor parser script files are stored in the Toad\User Files folder.
Long and Short PL/SQL Editor Parser Scripts
Toad contains two flavors of editor parser scripts: SHORTSCR.TXT and
LONGSCR.TXT. During the install, it defaulted to SHORTSCR.TXT.
LONGSCR.TXT contains almost twice as many items for syntax highlighting and will give you access to over a thousand reserved words and keywords. The longer list might affect performance depending on your editor contents.
If you want to change to LONGSCR.TXT, you can copy LONGSCR.TXT over
PLSQLSCR.TXT. Another way to change your selection is via the View |
Options | Parser Scripts tab. Change the path for the PLSQL Parser Script
File (PLSQLSCR.TXT) to the desired file (LONGSCR.TXT or SHORTSCR.TXT).
If you want to add or remove Oracle SQL Reserved words, PL/SQL Reserved words, or Oracle Keywords from the lists that are syntax highlighted, then edit the PLSQLSCR.TXT file. If you edit the PLSQLSCR.TXT file be careful, because no support will be provided for altered scripts. If you want to add or remove words from the syntax highlighting of the other languages, edit the corresponding editor parser script for that language.
77
Toad for Oracle
Bookmarks
Bookmarks help you manage files. They are especially useful when you are trying to manage large files. Mark a position within the SQL Editor so that you can easily jump back to that line. You can set up to 10 separate bookmarks within one editor.
Bookmarks can be accessed from the right-click menu.
To set a bookmark
• Press <CTRL><SHIFT># where # is a number between 0 and 9. A small green box containing the bookmark number will appear in the editor gutter.
To jump back to a bookmark
• Press <CTRL># where # is a previously defined bookmark between
0 and 9.
Note that these keystrokes assume you have not altered the default editor keys.
User defined keystrokes for common editing commands
Click Edit | Editor Options | Key Assignments to access the Key
Assignments window.
Select the command from the left panel, and its associated Key Assignment displays in the right panel. The Add or Edit buttons display easy-to-follow steps so that you can add new key assignments or edit existing ones. The Delete button deletes the highlighted key assignment.
78
SQL Editor
Auto Replace Substitutions
A substitution is a text phrase that corresponds to replacement text. For example, if you specify a substitution pair of ACT = ACTIVITY_CENTERS, when you type ACT and press <SPACE> (or other configurable word delimiters), ACT is automatically replaced by ACTIVITY_CENTERS. If you specify a substitution pair of NDF = NO_DATA_FOUND and you type NDF and press a delimiter, NDF is automatically replaced by NO_DATA_FOUND.
To access Auto Replace, go to the Edit| Editor Options| Auto Replace tab.
Toad already has a list of Auto Replace Substitutions specified including: teh = the, ndf = NO_DATA_FOUND, (c) = ©.
The Toad parser scripts come with a handful of Substitution pairs, but you may edit and add to the list on the Editor Options window. Once saved from this window, the substitution pairs will be saved to an ASCII file named
[Language]SUB.TXT in the User Files directory.
The Auto Replace substitutions for each language type are stored in separate files in the Toad\User Files folder.
LANGUAGE
HTML
INI
JAVA
PL/SQL
TEXT
AUTO REPLACE
SUBSTITUTION FILE
HTMLSUB.TXT
INISUB.TXT
JAVASUB.TXT
PLSQLSUB.TXT
TEXTSUB.TXT
Thereafter, you can continue to alter the substitutions in the Editor Options window or directly in the [Language]SUB.TXT file.
79
Toad for Oracle
Code Completion Templates
Code templates expand upon the Auto Replace Substitution concept, but a manual keystroke (<CTRL><SPACE>) is required to perform the substitution.
Code templates are more than a single phrase and can contain line feeds. If a vertical pipe character is in the code template, the cursor will be placed at that point in the template. Code templates are loaded from the text file
[Language].DCI from the Toad\User Files folder, where [Language] can be
HTML, INI, JAVA, PLSQL, or TEXT.
Example: One of the code templates defined in PLSQL.DCI is:
[crbl | entire cursor block]
DECLARE
CURSOR c1 IS
SELECT | FROM WHERE;
c1rec IS c1%ROWTYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO c1rec;
EXIT WHEN c1%NOTFOUND;
END LOOP;
CLOSE c1;
END;
Where:
"crbl" is the macro for the template (the text YOU type)
"entire cursor block" is the description of the template everything following until the next template is the body of the template
Do not leave spaces between the end of the template description and the final right bracket! NT4.0 API calls to manage profile strings have a bug which will cause reading of the templates file to fail.
80
SQL Editor
If you type "crbl" and press <CTRL><SPACE>, Toad will load the body of the template and place the cursor at the position of the vertical pipe char. If the word or phrase under the cursor does not match an existing macro verbatim, a dropdown list of all macros is displayed.
\User Files\PLSQL.DCI contains sample templates which you can alter to suit your needs.
You can edit the code completion templates directly in the Edit | Editor
Options dialog, Code Templates tab, or via text editor on the *.DCI files.
Undo/Redo
These basic editing commands are accessed from the Edit menu.
COMMAND
Undo
Redo
KEYBOARD SHORTCUT
<CTRL>Z
<SHIFT><CTRL>Z
Comment Code Block
This function comments the selected block of text by adding "--" before each line. This is available on the right-click menus of the editors and is also on the
Main Edit menu.
Uncomment Code Block
This function uncomments the selected block of text by removing "--" from the beginning of each line. This is available on the right-click menus of the editors and is also on the Main Edit menu.
81
Toad for Oracle
Locate Closing Parenthesis (Find Closing
Block)
Finds the closing parenthesis, "END" for matching "BEGIN", or "END IF" for matching "IF."
If you select/highlight a left parenthesis, "BEGIN", or "IF", this function will show the matching right parenthesis, "END" or "END IF."
Find Closing Block can only be accessed on the right-click menus of the SQL
Editor and Procedure Editor.
Find, Find Next, Find Previous, and Replace
You access the Find and Replace editing options from the Edit menu.
FUNCTION
Find
Find Next
Find Previous
Replace
KEYBOARD SHORTCUT
<CTRL>F
F3
<SHIFT>F3
<CTRL>R
On the Find and the Find and Replace dialogs (Edit|Find, Edit | Replace), you can check the Regular expressions check box to use regular expression syntax for your search. Regular expressions specify text by its characteristics rather than its exact characters. For example, you can find and replace tabs with spaces. The following are some examples of regular expressions.
\f
\t
\r
\n
\b
\s
Carriage return
New line
Form feed
Tab character
Backspace
Space
82
SQL Editor
Show All following a search
To get to this function, click Edit| Show All.
Only to be used after a FIND. After you use FIND to search through your text for a word or phrase, you can click Show All from the Edit menu and Show All will display wavy red lines under every occurrence of the search phrase. The lines will be removed following any change to the text in the editor.
Configurable Print Options
The Edit | Editor Options| General Options tab provides printing options.
You can check/uncheck the Syntax Highlighting option from the View| Options
|
General page.
Use Syntax Highlighting when Printing Source Code
This option is checked by default, which means the report will print using the same colors that are displayed in the window. So, color printing is the default for printing SQL Edit text or Stored Procedure Edit code.
If you uncheck the View| Options| General| Use syntax highlighting
when printing source code option, then the SQL text or Stored Procedure Edit code will be printed in standard black and white.
If you get garbage characters on your color printout, turn off the Use syntax
highlighting when printing source code and then try to print again.
83
Stáhnout
Reklama