Home » Products » UltraEdit/UEStudio » Configuration / Preferences » Integrated Applications

Display/Modify Templates command

Use this command to display the Modify Templates dialog.  A template is predefined text that may be recalled automatically at a later time and inserted into a file.  The Template Group dropdown may be used to select which templates are listed in the Templates pane.  

 

Templates are organized in three groups: Global, Environments, and Languages.  Global templates are always available, Environment templates are only available when the environment they're associated with is loaded, and Language templates are associated with languages specified for syntax highlighting and are only available when editing files with extensions that match that language.

 

An unlimited number templates may be defined.  Each of the first 20 global templates may be recalled at a later time using hot keys Alt+0 through Alt+9, and Shift+Alt+0 through Shift+Alt+9, or any of the templates may be recalled with the Insert Template dialog or by user-defined hot keys.

 

Each template may optionally have a name associated with it, that if defined will show up on the tooltips on the toolbar and in the list of templates when inserting a template.

 

Global templates are stored in the UETMPLTE.DAT  file in the default directory or the directory specified under the Directories branch under Configuration in the Advanced menu if using the default environment.  The built-in environments and the customized user environments save the Environment templates in an environment-related file in the environment directory.  Language templates are stored in the default wordfiles directory as they are associated with the languages specified in the wordfiles.

 

Placeholder Variables

Using the syntax [+VariableName+], a user may define "placeholder" variables in templates, and when the template is inserted, the placeholders will be highlighted in a template editing mode so that the user can type over the placeholder value to rename the variable.  All occurrences of the variable are then updated.  Pressing TAB will cause focus to move to the next placeholder variable.  For example if the user inserts the template:

 

// function [+function+]

[+scope+] function [+function+] () {

  ^

}

 

and types "myFunc" for the [+function+] variable and "private" for the [+scope+] variable, he would see this:

 

// function myFunc

private function myFunc () {

  ^ <-- caret blinking here

}

 

If ESC or ENTER is pressed the template will be permanently inserted into the active document and template editing mode will no longer be active.

 

A template may also 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 Control Key + value.

 

Additionally, for extended date and time formatting, UltraEdit supports the following enhanced functionality:

 

Time

To specify the USER TIME format use the following syntax in your template:

 

For local time use the following markers:

 

[TIME_USER]...time format string here...[TIME_USER_END]

 

For system time use the following markers:

 

[TIME_USER_SYS]...time format string here...[TIME_USER_SYS_END]

 

Note: TIME_USER_SYS is UTC (Coordinated Universal Time).  In general usage this may be thought of as GMT (Greenwich Mean Time).

 

The time format string is defined as follows:

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.

 

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

 

For example, to get the time string

 

"11:29:40 PM"

 

use the following format string:

 

"hh':'mm':'ss tt"

 

This string MUST be between the markers, for example:

 

[TIME_USER]hh':'mm':'ss tt[TIME_USER_END]

 

Date

To specify the USER DATE format use the following syntax in your template:

 

For local date use the following markers:

[DATE_USER]...date format string here...[DATE_USER_END]

 

For system date use the following markers:

[DATE_USER_SYS]...date format string here...[DATE_USER_SYS_END]

 

The date format string is defined as follows:

Use the following elements to construct a format string. 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.

 

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.

 

For example, to get the date string

 

"Wed, Aug 31 94"

 

use the following format string:

 

"ddd',' MMM dd yy"

 

This string MUST be between the markers, for example:

 

[DATE_USER]ddd',' MMM dd yy[DATE_USER_END]   

 

Inserting Templates

If the option Auto-suggest smart template when typing is enabled under Advanced -> Configuration -> Templates, and the user pauses while typing a string that matches a defined template name, UltraEdit will "suggest" a template based on what was last typed, and the user may press TAB to insert the suggested template.

 

For example, if the user has a C/C++ template named "void" and is editing a *.cpp file and types "void" and then pauses briefly, UltraEdit will automatically insert the "void" template in a special "suggestion" mode.  To finish inserting the template, the user should press TAB.  The amount of time the user must wait before seeing a template suggested is defined in the after pausing for field under Advanced -> Configuration -> Templates.

 

Alternatively, while editing, the user may press Ctrl+Space to invoke the auto-complete dialog and any templates which are defined whose name matches the string next to the caret will be listed in the auto-complete dialog as well.  The user may choose a template here and insert this if desired.

 

Attachments
There are no attachments for this article.
Related Articles
Javascript Lint
Viewed 303 times since Mon, Oct 17, 2011
Boost Software License
Viewed 247 times since Thu, Oct 20, 2011