20.3 Using Code Formatter and Beautifier
20.3.1 Using Keyword Capitalization and Formatting Feature
SQL Assistant
TM can be configured to automatically format keywords as you type them. If the Keyword Capitalization feature is enabled, SQL Assistant
TM automatically changes keywords that you type the case specified in the Convert rule. For example, if you type ''alter table mytable'' and the Convert rule is set to Uppercase, SQL Assistant
TM automatically updates the entered text to ''ALTER TABLE mytable''.
20.3.2 Using Smart Auto-Indent Feature
If the Auto-Indent option is enabled, pressing Enter key in a SQL Editor will add a new line with the caret positioned on it, along with the indent which SQL Assistant
TM assumes to be reasonable in the current code point. The indent, in other words, the amount of spacing in the new line is calculated from the left side of the editor screen according to code format patterns for the current statement and relative to the indent of the previous line.
For example, if you code a procedure and within BEGIN...END construct you type text like below
BEGIN
IF my_variable > 0 THEN
END IF;
END$$
and press Enter key after word ''THEN'', SQL Assistant
TM will automatically insert a new line and enter as many spaces (or tabs) as configured in format patterns. The result would like below
BEGIN
IF my_variable > 0 THEN
|
END IF;
END$$
here the pipe sign represents the new position of the caret. In comparison if you press Enter after the line ''my_variable := 55;'' the indent of the inserted line will be the same as the indent of the previous line.
BEGIN
my_variable := 55;
|
END$$
Tip:
SQL Assistant
TM also automatically un-indent closing brackets, END, END IF, END LOOP, LEAVE and some other SQL statement closing constructs so that the indent of these SQL code elements matches the indent of the opening element.
20.3.3 Reformatting blocks of code
In addition to the automatic keyword format-as-you-type feature described in sec.
20.3.1, SQL Assistant
TM provides the capability of reformatting a selected block of code, or all the code in the current file. SQL Assistant
TM's Code Formatter reformats the selected block of code, or the entire text if nothing is selected.
There are several ways to invoke the feature:
- Use Ctrl+F11 hot key
- Use SQL Editor's context menus.
The code formatting is pattern-driven.
Important Notes:
If for whatever reason you want to undo the reformatting, use SQL Editor Undo features to undo the change. If the entire text is reformatted, you may need to use the Undo feature twice, to undo reformatted code insertion and then to undo editor's text reset retrospectively. This will restore the text in the Editor as it was before you invoked SQL Assistant
TM's Code Formatter feature.
Copyright © 2007 - 2009 HoneySoftware - All Rights Reserved
Submit feedback on this topic.