Text Commands

Text Commands are keywords used in templates. This article provides a detailed description of each supported Text Command. To insert a Text Command into your template expansion, use the (Select to insert) drop-down list.

Ext_Templates_TextCommands

Note

Text Commands are inserted without their signature. If you need to pass one or more parameters, add them (enclosed in parentheses) after the Text Command name manually.

The table below allows you to quickly navigate to the description of any Text Command. The descriptions are presented successively after the table.

A ... C D ... F F ... M M ... S S ... T T ... Z
AddNamedBookmark DeleteAfterFormat ForEach Member SoftAnchor TypeLink
AddNamespace DeleteRight ForEachColumn Method SoftCaret TypeName
AlignNewLines EndFormat ForEachRow Namespace StoreInsertionPoint
BeginFormat EscapeQuotes Format Paste SuppressActionHint
BlockAnchor ExpandTemplate FullTypeName PasteType TagLink
Caret Field GotoFileBottom PopIndent Target
Class FieldEnd GotoFileTop PushIndent TextCommandBegin
Class.Method FieldStart GotoInsertionPoint ReturnType TextCommandEnd
ClearFields FinalTarget HardMarker SetLeadingWhiteSpace TextLink
CompleteWord FinalTargetEnd Link SmartConstructor TrimLeft
Cursor FinalTargetStart Marker SmartReturn TypeKind


«AddNamedBookmark(bookmark_name)»

Position Parameter Description
1 Bookmark name Number from 1 to 6 or any other text

Adds the named bookmark at the specified location. Use numbers from 1 to 6 as a parameter to place a bookmarks to which you can jump using the Alt+1, ..., Alt+6 shortcuts. You can also pass a string to this Text Command.


«AddNamespace(namespace_name,[namespace_name],...,[namespace_name])»

Position Parameter Description
1 Namespace name The name of the namespace to reference
2, 3, ..., 8 Namespace name (optional) Coma-separated namespace names

Adds specified namespace references (passed as a parameter to this Text Command) to the active file if these namespaces are not already referenced.

An alternative way to specify the dependent namespaces is described in the Referencing Namespaces article.


«AlignNewLines(boolean_flag)»

Position Parameter Description
1 Boolean flag "true" or "false"

Enables or disables new line alignment. If line alignment is disabled, template expansion will be inserted as is without any additional characters.


«BeginFormat»

Marks the beginning of a text formatting operation. Any template expansion between this Text Command and the EndFormat Text Command will be explicitly formatted according to user code style settings.


«BlockAnchor»

Marks the end of a text selection. After text expansion is complete, the text between the Cursor (Caret) and this Text Command will be selected.

The usage of this Text Command is detailed in the Using Text Commands article.


«Caret»

Places the caret at the point where this Text Command appears in an expansion. If an expansion contains multiple «Caret» Text Commands, the caret will be positioned on the last one in the expansion. This Text Command is identical to the Cursor Text Command.

The usage of this Text Command is detailed in the Using Text Commands article.


«Class»

Inserts the name of the active class.


«Class.Method»

Inserts the current class name plus the current method name separated with a dot. If there is no active method, this Text Command inserts the active class name.


«ClearFields»

Clears all text fields (added with Field and FieldStart Text Commands) in the active document.


«CompleteWord»

Invokes Visual Studio's IntelliSense at the caret position after text expansion is completed.


«Cursor»

Places the caret at the point where this Text Command appears in an expansion. If an expansion contains multiple «Cursor» Text Commands, the caret will be positioned on the last one in the expansion. This Text Command is identical to the Caret Text Command.


«DeleteAfterFormat(text_to_delete)»

Position Parameter Description
1 Text to delete Any string

Deletes the specified text (passed as a parameter) after formatting of the language services has been performed.


«DeleteRight(text_to_delete)»

Position Parameter Description
1 Text to delete Any string

Deletes the specified text (if it exists) to the right of the caret.


«EndFormat»

Marks the end of the text formatting operation and formats any text expanded between the position where this Text Command is encountered and the place where the BeginFormat Text Command was encountered.


«EscapeQuotes»

Replaces regular quote characters (") with escaped quotes (") with a preceding slash character (e.g., for C# strings).


«ExpandTemplate(template_name)»

Position Parameter Description
1 Template name The name of the template to expand.

Expands the specified template at the caret. This Text Command is almost equivalent to the «:template_name», however it can accept a String Provider as a parameter, which enables you to expand different templates depending on variable values or context.

The usage of Text Commands that expand a template is detailed in the Using Variables article.


«Field(default_value,[description],[clear_on_first_activation])»

Position Parameter Description
1 Default value The initial field value
2 Description (optional) The hint, which will be displayed when the field is active
3 Clear on first activation (optional) "true" or "false"

Adds a field to a text expansion.

The usage of this Text Command is detailed in the Providing Input Fields article.


«FieldEnd»

Marks the end of a text field during expansion. Should be preceded by a FieldStart Text Command.

The usage of this Text Command is detailed in the Providing Input Fields article.


«FieldStart([description],[clear_on_first_activation])»

Position Parameter Description
1 Description (optional) The hint, which will be displayed when the field is active
2 Clear on first activation (optional) "true" or "false"

Marks the start of a text field during expansion. Should be followed by a FieldEnd Text Command.

The usage of this Text Command is detailed in the Providing Input Fields article.


«FinalTarget([template])»

Position Parameter Description
1 Template (optional) The template to expand when the target was reached

Adds a final target for text fields to a template expansion. Text fields can have two different kinds of targets: a normal target created through the Target Text Command, and a final target created through this Text Command. Normal targets are cleared any time a new text expansion occurs that includes a text field, and are useful when a template might be called (nested) one or more times from another template (if nested multiple times, only the last Target would survive, however if a FinalTarget Text Command was encountered during this expansion, it would override any previously encountered Targets). While normal targets can be set and cleared multiple times during a single template expansion, a final target is only cleared when another FinalTarget Text Command is encountered, or after expansion if the last target is reached and the Enter key is pressed, or when a brand new text expansion occurs that contains this FinalTarget Text Command. Only one FinalTarget is allowed per document at any time.


«FinalTargetEnd»

Marks an ending point for Text Fields to a template expansion. Text Fields can have two targets. A normal target created through the Target Text Command, and a final target created through this (or FinalTarget) Text Command. Normal targets are cleared any time a new text expansion expands that includes a text field, however a final target is only cleared when the last target is reached and Enter is pressed, or when a new text expansion expands that contains this FinalTarget Text Command (only one FinalTarget is allowed per document at any time).


«FinalTargetStart»

Marks a starting point for a final target for text fields to a template expansion. Text fields can have two targets. A normal target created through the Target Text Command; and a final target created through this (or FinalTarget) Text Command. Normal targets are cleared any time a new text expansion expands that includes a text field, however, a final target is only cleared when the last target is reached and Enter is pressed, or when a new text expansion expands that contains this FinalTarget Text Command (only one FinalTarget is allowed per document at any time).


«ForEach(iteration_bounds,main_template,[prefix_template],[between_template],[postfix_template])»

Position Parameter Description
1 Iteration bounds The string composed by the following template "[visibility] member in scope" (see Iterating Through Elements)
2 Main Template The template to expand for each element
3 Prefix Template (optional) The template to expand before elements
4 Between Template (optional) The template to expand between elements
5 Postfix Template (optional) The template to expand after elements

Iterates through language elements in the active or specified scope (Me, this, base, inherited, method, property, ClipType, ClipClass, File, or block) calling the specified template once for each item found. Elements that can be iterated include Field, Parameter, Property, Member, Method, Event, Class, etc. Members can be preceded by a visibility filter (e.g., "public", "private", etc.). Inside the template you're calling, use «?Get(itemName)» and «?Get(itemType)» to get the name and type of each item iterated.

The usage of this Text Command is detailed in the Iterating Through Elements article.


«ForEachColumn(row_template,[row_begin_template],[row_end_template],[skip_if_one_row])»

Position Parameter Description
1 Row Template The template to expand for each row
2 Row Begin Template (optional) The template to expand before rows
3 Row End Template (optional) The template to expand after rows
4 Skip if one row (optional) Do not expand on a single column ("true" or "false")

Calls the specified template (passed as a parameter to this Text Command) once for each column in the TableColumns variable (which can be set using the «?Set(variable_name,value)» string provider). For each column iterated, the variable ColumnNum is incremented and its value can be queried using the «?Get(variable_name)» string provider.

Note

This Text Command is used in the "t" template in XAML.


«ForEachRow(column_template,[column_begin_template],[column_end_template],[skip_if_one_column])»

Position Parameter Description
1 Column Template The template to expand for each column
2 Column Begin Template (optional) The template to expand before columns
3 Column End Template (optional) Do not expand on a single column ("true" or "false")

Calls the specified template (passed as a parameter to this Text Command) once for each row in the TableRows variable (which can be set using the «?Set(variable_name,value)» string provider). For each row iterated, the variable RowNum is incremented and its value can be queried using the «?Get(variable_name)» string provider.

Note

This Text Command is used in the "g" template for XAML.


«Format»

Formats text span from start of expansion to current insertion point.


«FullTypeName»

Inserts the full name of the current type (class, struct, interface, module or delegate), for example System.Text.StringBuilder.


«GotoFileBottom»

Takes the caret to the bottom of the active document.


«GotoFileTop»

Takes the caret to the top of the active document.


«GotoInsertionPoint»

Moves the caret to a new insertion point.


«HardMarker([lifetime])»

Position Parameter Description
1 Lifetime (optional)

Drops a hard standard marker. You can pass an optional integer parameter to specify life in seconds.


«Link(identifier_name,[in_provider],[out_provider])»

Position Parameter Description
1 Identifier name The text to keep in sync.
2 In provider (optional) The "In" StringProvider that converts other links into the text that this link will show.
3 Out provider (optional) The "Out" StringProvider that converts this link text into the text that other links will show.

Creates a linked identifier in the code. Linked identifiers keep several references to the same identifier in sync, which means changes to one identifier are instantly propagated to the others. To use this Text Command, simply specify initial name of the identifier as the first parameter. Subsequent calls to a Link with the same variable name will expand to the same value, and will all later change to stay in sync with any changes made to any Link. If you need to create a variation of the identifier (for example, a field declaration linked to a property name), you can specify two additional parameters that are the names of string providers that convert the data to and from the needed representation.

The usage of this Text Command is detailed in the Linking Identifiers article.


«Marker([lifetime])»

Position Parameter Description
1 Lifetime (optional) The marker will be disposed after the time specified here

Drops a soft transient marker. You can pass an optional integer parameter to specify life in seconds.

The usage of this Text Command is detailed in the Using Text Commands article.


«Member»

Inserts the name of the active method, property or field.


«Method»

Inserts the name of the active method.


«Namespace»

Inserts the name of the active namespace.


«Paste»

Pastes the contents of the clipboard.

The usage of this Text Command is detailed in the Using Text Commands article.


«PasteType»

Inserts the type of the identifier on the clipboard. For example if myVar (declared as a System.Boolean) was on the clipboard, bool would be inserted.


«PopIndent»

Pops the previously-pushed indent level from the indent stack. All future templates will use the newly-popped indent level until it is changed.


«PushIndent»

Pushes the current indent level to the indent stack, allowing you to change the indent level and then restore it later (with a call to the PopIndent Text Command).


«ReturnType»

Inserts the return type of the active method.


«SetLeadingWhiteSpace(whitespace)»

Position Parameter Description
1 Whitespace The string that will be added to each line of the expansion

This Text Command sets a leading white space for the rest of the expansion.


«SmartConstructor»

Generates a constructor for the current class using the Smart Constructor feature.


«SmartReturn»

This Text Command generates a smart return statement for the current method. If the current method returns a type, a best guess for the return value (based on identifiers in scope) will be suggested.


«SoftAnchor»

Places the selection anchor at the point where this Text Command appears in an expansion unless a BlockAnchor Text Command appears elsewhere in the template. If an expansion contains multiple SoftAnchor Text Commands (but is without a BlockAnchor Text Command), the selection anchor will be positioned on the last SoftAnchor Text Command in the expansion. If an expansion contains a mix of SoftAnchor and BlockAnchor Text Commands, the selection anchor will be positioned on the last BlockAnchor Text Command in the expansion.


«SoftCaret»

Places the caret at the point where this Text Command appears in an expansion unless a Caret or Cursor Text Command appears elsewhere in the template. If an expansion contains multiple SoftCaret Text Commands (without Caret and Cursor Text Commands), the caret will be positioned on the last SoftCaret Text Command in the expansion. If an expansion contains a mix of SoftCaret with Caret and/or Cursor Text Commands, the caret will be positioned on the last Caret or Cursor Text Command in the expansion.


«StoreInsertionPoint([insertion_point_name])»

Position Parameter Description
1 Insertion Point Name (optional) Any string

Stores a new insertion point at the current caret position. Return to this point can be accomplished using the GotoInsertionPoint Text Command.


«SuppressActionHint»

Suppresses the action hint associated with a template expansion.


«TagLink»

Creates a link in the code that supports editing tags (identifier characters plus the characters ":", "_", ".", and "-"). Links keep several references to the same tag in sync, which means changes to one reference are instantly propagated to others. To use this Text Command, simply specify the tag text as the first parameter. Subsequent calls to a Link with the same tag text will expand to the initialized value of the first, and will later change when any other Link is changed.


«Target([template_name])»

Position Parameter Description
1 Template name (optional) The template to expand when the target was reached

Adds a target location to jump to after template expansion text fields have all been accepted. When the last text field inside a document is active, a visual target indicator appears showing the location where the caret will move when the last text field is accepted (typically through the Enter key). When the last text field in a document has been accepted, the caret is moved to the target location and the visual indicator is removed.


«TextCommandBegin»

Inserts a literal Text Command Start character ("«").


«TextCommandEnd»

Inserts a literal Text Command End character ("»").


«TextLink»

Creates a text link in code. Text links keep several references to the same text in sync, which means changes to one reference are instantly propagated to others. To use this Text Command, simply specify the text as the first parameter. Subsequent calls to a TextLink with the same text will expand to the initialized value of the first.


«TrimLeft»

Removes all white space to the left of the insertion point.


«TypeKind»

Inserts the keyword for the current type.


«TypeLink»

Creates a type-aware link in code. Type-aware links keep several references to the same type name in sync, which means changes to one reference are instantly propagated to others. To use this Text Command, simply specify the type name as the first parameter. Subsequent calls to a TypeLink with the same type name will expand to the initialized value of the first.

Note

This text command is similar to Link, but allows angle brackets (< and >) to be a part of a linked text.


«TypeName»

Inserts the name of the current type (class, struct, interface, module or delegate), for example StringBuilder.

Note

This text command is similar to Link, but allows any symbol be a part of a linked text.