This documentation is archived and is not being maintained.

Indent Method (TextSelection Object)

Visual Studio .NET 2003

Indents the selected lines by the given number of indentation levels.

[Visual Basic .NET]
Public Sub Indent( _
   Optional ByVal Count As Integer = 1 _
) 
[Visual Basic 6]
Sub Indent( _
   Optional ByVal Count As Long = 1 _
) 
[C++]
HRESULT __stdcall Indent(
   long Count
);
[C#]
public void Indent(
   int Count
);
[JScript .NET]
public function Indent(
   Count : int
)

Parameters

Count
Optional. The number of display indent levels to indent each line in the selected text. The default is 1.

Remarks

Indents the selected text by the number of display columns indicated by the global setting for one indentation level. Indent does not do smart formatting or indent lines based on the context of the code. Tabs and spaces are inserted, depending on the global setting for whether to use tabs when indenting. The indentation may consist of multiple tab and space characters, depending on the global setting for how many spaces a tab equals.

Indent behaves differently depending on whether the selected text is continuous or columnar. If it's continuous, all lines partially or completely within the selection are indented at the first column. If it's a columnar selection, the selected text is indented at the left edge of the selection.

Indent behavior depends on whether the selected text is the entire line, or only a portion of it. If only a portion of the line is selected, the selected portion is deleted and the remainder is indented either one indent level or Count number of columns.

If the value of Count is negative, then Indent performs like the UnIndent Method (TextSelection Object).

Indent fails if the value of Count is greater than or equal to 10,000.

Example

Sub IndentExample()
   ' Before running this example, open a text document.
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection
   ' Go to first line in document and indent it.
   objSel.GotoLine(1, False)
   objSel.Indent(1)
End Sub

See Also

Applies To: TextSelection Object

Show: