TextTransformation.ClearIndent Method

Resets the CurrentIndent to an empty string.

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

Syntax

'宣言
Public Sub ClearIndent
'使用
Dim instance As TextTransformation

instance.ClearIndent()
public void ClearIndent()
public:
void ClearIndent()
public function ClearIndent()

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 how to call the ClearIndent method from a text template. Paste this code into any text template file and run the text template transformation to see the results.

<#
PushIndent("Indent1>  ");
PushIndent("Indent2>  ");
WriteLine("Test");

PushIndent("Indent3>  ");
PushIndent("Indent4>  ");
WriteLine("Test");

ClearIndent();

WriteLine("Test");
#>
<#
PushIndent("Indent1>  ")
PushIndent("Indent2>  ")
WriteLine("Test")

PushIndent("Indent3>  ")
PushIndent("Indent4>  ")
WriteLine("Test")

ClearIndent()

WriteLine("Test")
#>

This example produces the following output:

Indent1> Indent2> Test

Indent1> Indent2> Indent3> Indent4> Test

Test

Permissions

See Also

Concepts

Generating Artifacts Using Text Templates

Reference

TextTransformation Class

TextTransformation Members

Microsoft.VisualStudio.TextTemplating Namespace

CurrentIndent

PushIndent

PopIndent