TextTransformation.CurrentIndent Property

 

Gets the current indent text, which is prefixed to each line of the generated text output.

Namespace:   Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating.12.0 (in Microsoft.VisualStudio.TextTemplating.12.0.dll)

public string CurrentIndent { get; }

Property Value

Type: System.String

A String that contains the text that is prefixed to each line of the generated text output.

The CurrentIndent represents text that is prefixed to each line of the generated text output. The indent text can be spaces only, for example "    ", or it can include words. PushIndent adds text to CurrentIndent, and can be called more then once. PopIndent removes the most recently added text from CurrentIndent, and can be called more than once. ClearIndent removes all text from the CurrentIndent.

The following code example demonstrates calling the CurrentIndent property from a text template. Paste this code into any text template file and run the text template transformation to see the results.

<#
PushIndent("Indent: ");

WriteLine("Test");
WriteLine(CurrentIndent);
WriteLine(CurrentIndent.Length.ToString());

ClearIndent();
#>

This example produces the following output:

Indent: Test

Indent: Indent:

Indent: 8

Return to top
Show: