Share via


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.11.0 (in Microsoft.VisualStudio.TextTemplating.11.0.dll)

Syntax

'Declaration
Public ReadOnly Property CurrentIndent As String
public string CurrentIndent { get; }
public:
property String^ CurrentIndent {
    String^ get ();
}
member CurrentIndent : string with get
function get CurrentIndent () : String

Property Value

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

Remarks

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.

Examples

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();
#>
<#
PushIndent("Indent: ")

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

ClearIndent()
#>

This example produces the following output:

Indent: Test

Indent: Indent:

Indent: 8

.NET Framework Security

See Also

Reference

TextTransformation Class

Microsoft.VisualStudio.TextTemplating Namespace

PushIndent

PopIndent

ClearIndent

Other Resources

Code Generation and T4 Text Templates