A template is predefined text that is stored and can be recalled later to insert into a file. The Modify templates dialog allows you to create, modify, delete, and organize templates.
The Template group drop down can be used to select the group for which templates are listed in the Templates pane. Templates are organized in four groups:
Templates are stored in a plain-text XML format, although it is generally recommended that templates are created and modified directly through the Modify templates dialog and not directly in the file itself.
Global templates are always available no matter which layout, project, or coding language you're using. Global templates are stored in the UETMPLTE.TPL file in the default templates directory (which is typically %APPDATA%\IDMComp\UltraEdit\templates on Windows), or the directory manually set in Settings » Directories.
Layout templates are only available when the layout they're associated with is loaded. Layout templates are stored in layout-related files in the environments subfolder of the global templates directory.
Language templates are associated with coding languages specified for Syntax highlighting and are only available when editing files with extensions that match that language as defined in the wordfile. Language templates are stored in the default wordfiles directory as shown in Settings » Editor Display » Syntax Highlighting.
Project templates are only available when the project they're associated with is loaded. Project templates are stored in the directory/file specified in the Project settings dialog.
You can create an unlimited number of templates. Each template must be named, and the name is used in the ribbons, menus, and toolbars as well as in the Template list. The name is shown in the template list column in the left side of the "Modify templates" dialog.
The following options are available in the "Modify templates" dialog:
Add (+) / remove (x) buttons
Use these buttons to add and delete templates from the selected group.
Up / down buttons
Use these buttons to move the selected template up or down in the template list. The order of templates shown in the template list of the "Modify templates" dialog is also the order used to display templates in the Template list.
Description
You can provide an optional description for the template of up to 79 characters. The description is shown in the tooltip displayed when hovering over the template in the Template list. If a description is not provided, the tooltip will show an extract of the template itself.
Do not insert in Comments / Strings
These options are only available for language templates. If checked, the template will not be automatically suggested when its name is typed in a comment or string of the associated syntax highlighting language.
? button
This button opens a dialog with a list of available template variables and formatting options.
Content field
To create a template, simply type the text of the template into this field.
You can use the caret (^) in the template to represent where the caret should be positioned after the template is inserted. For example, if you have a template consisting of <myTag></myTag>
, and you want the caret to be positioned between the 2 tags, you would create the template as <myTag>^</myTag>
. To include a literal caret (^) as part of your template, escape it with itself; i.e., "^^" would insert a literal "^".
Using the syntax [+VariableName+]
within a template, you can define "placeholder" variables in templates. When the template is inserted, you can type the value for the placeholder. All occurrences of the placeholder variable within the template are then updated. Pressing Tab will move focus to the next placeholder variable. For example if you insert the template:
// function [+function+]
[+scope+] function [+function+] () {
^
}
...and type "myFunc" for the [+function+]
variable and "private" for the [+scope+]
variable, you would see this:
// function myFunc
private function myFunc () {
^
<-- caret blinking here
}
Selectable values allow you to insert a variable with several different pre-defined choices which can be selected during template insertion via the auto-complete drop down. To add selectable values to a template variable, use the following syntax:
[+defaultVal|selectableVal1|selectableVal2|selectableVal3+]
The pipe character (|) is used to delimit different selectable values. In the above example, when the template is inserted, the variable would have a default value of defaultVal and the auto-complete dialog would open immediately to allow you to choose one of the other 3 options. Once you select an item from the auto-complete drop down by pressing Enter, UltraEdit will shift focus to the next variable (or if this is the only variable, insert the template).
In some cases, you may prefer to use a completely different value for a template variable instead of one of the pre-defined values. In this case, you can simply tab to the variable during template insertion and begin typing a new value. The auto-complete dialog will disappear after you begin typing new text. At any time, you can press Ctrl + Spacebar to make the auto-complete dialog with the selectable values visible again.
A template can contain special text strings that are translated at the time the template is recalled. These special strings are:
[DATE_DMY]
|
Is translated into the current date with the format day/month/year. |
[DATE_MDY]
|
Is translated into the current date with the format month/day/year. |
[DATE_TEXT]
|
Is translated into the current date with the date displayed as text. |
[TIME]
|
Is translated into the current time in 24 hour format. |
^
|
This indicates the position at which to place the cursor after the template has been inserted. |
[FULL_FILE_NAME]
|
Is translated into the full path and filename of the active document. |
[FILE_PATH]
|
Is translated into the drive and path of the active document. |
[FILE_NAME]
|
Is translated into the root filename of the active document. |
[FILE_EXTENSION]
|
Is translated into the file extension of the active document with the "point", i.e. ".txt". |
[FILE_EXTENSION_NP]
|
Is translated into the file extension of the active document without the "point", i.e. "txt". |
[$REPLACE$]
|
Is replaced with selected text in the active document. The selection will be converted to uppercase text when inserted with the template. |
[$replace$]
|
Is replaced with selected text in the active document. The selection's current case will be maintained when it is inserted with the template. |
Note - ^ refers to the character '^', not the Ctrl key.
For extended date and time formatting, UltraEdit supports special template strings.
Time
To specify and customize the format of the local time, use the following syntax in your template:
[TIME_USER]...format customizations here...[TIME_USER_END]
To specify and customize the format of the UTC (GMT, or Greenwich Mean Time) time, use the following syntax in your template:
[TIME_USER_SYS]...format customizations here...[TIME_USER_SYS_END]
The time format customizations are as follows:
String | Meaning |
---|---|
h | Hours with no leading zero for single-digit hours; 12-hour clock |
hh | Hours with leading zero for single-digit hours; 12-hour clock |
H | Hours with no leading zero for single-digit hours; 24-hour clock |
HH | Hours with leading zero for single-digit hours; 24-hour clock |
m | Minutes with no leading zero for single-digit minutes |
mm | Minutes with leading zero for single-digit minutes |
s | Seconds with no leading zero for single-digit seconds |
ss | Seconds with leading zero for single-digit seconds |
t | One character time marker string, such as A or P |
tt | Multicharacter time marker string, such as AM or PM |
If you use spaces to separate the elements in the format string, these spaces will appear in the same location in the template. The letters must be in uppercase or lowercase as shown (for example, "ss", not "SS"). Characters in the format string that are enclosed in single quotation marks will appear in the same location and unchanged in the template.
For example, to get the time string
11:29:40 PM
...use the following format string between the time markers:
[TIME_USER]hh':'mm':'ss tt[TIME_USER_END]
Date
To specify and customize the format of the local date, use the following syntax in your template:
[DATE_USER]...format customizations here...[DATE_USER_END]
To specify and customize the format of the UTC date, use the following syntax in your template:
[DATE_USER_SYS]...format customizations here...[DATE_USER_SYS_END]
The date format customizations are as follows:
String | Meaning |
---|---|
d | Day of month as digits with no leading zero for single-digit days. |
dd | Day of month as digits with leading zero for single-digit days. |
ddd | Day of week as a three-letter abbreviation. |
dddd | Day of week as its full name. |
M | Month as digits with no leading zero for single-digit months. |
MM | Month as digits with leading zero for single-digit months. |
MMM | Month as a three-letter abbreviation. |
MMMM | Month as its full name. |
y | Year as last two digits, but with no leading zero for years less than 10. |
yy | Year as last two digits, but with leading zero for years less than 10. |
yyyy | Year represented by full four digits. |
If you use spaces to separate the elements in the format string, these spaces will appear in the same location in the template. The letters must be in uppercase or lowercase as shown in the table (for example, "MM" not "mm"). Characters in the format string that are enclosed in single quotation marks will appear in the same location and unchanged in the template.
For example, to get the date string
Wed, Aug 31 94
...use the following format string between the time markers:
[DATE_USER]ddd',' MMM dd yy[DATE_USER_END]
Templates can be inserted into the active file through any of the following methods:
If Auto-suggest smart template when typing is enabled in Settings » Templates (it is by default), then when you type the name of any template (global, layout, project, or language), the template will be automatically suggested and shown in a "suggestion" mode in the edit window.
To accept the suggested template and add it to the file, press Tab.
Alternatively, while editing, you can press Ctrl + Spacebar to invoke the auto-complete dialog, and any templates names matching the string next to the caret (either wholly or partially) will be listed in the auto-complete dialog as well. You can use the up / down arrow keys to select a template shown in the auto-complete dialog, then press Enter to insert it.
If the template contains placeholder variables, UltraEdit will enter a special template editing state where you can set / select variables before the template is permanently added to the file. You can jump between different template variables via the Tab key. After setting variables in this mode, press ESC or Enter to finalize the template and insert it into the file.
If templates exist with the same name under different groups, the precedence used in auto-suggesting is as follows:
See also: