This documentation is archived and is not being maintained.

TextSelection.Insert Method

Inserts the given string at the current insertion point.

Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)

void Insert (
	[InAttribute] string Text,
	[OptionalAttribute] [InAttribute] int vsInsertFlagsCollapseToEndValue
)
void Insert (
	/** @attribute InAttribute() */ String Text, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ int vsInsertFlagsCollapseToEndValue
)
function Insert (
	Text : String, 
	vsInsertFlagsCollapseToEndValue : int
)

Parameters

Text

The text to insert.

vsInsertFlagsCollapseToEndValue

One of the vsInsertFlags values indicating how to insert the text.

[Visual Basic]

Sub InsertExample()
   ' Before running this example, open a text document.
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection
   ' Go to the first line in document and select it.
   objSel.GotoLine(1, True)
   ' Insert some new lines and some text.
   objSel.NewLine(3)
   objSel.Insert("A new line", vsInsertFlags.vsInsertFlagsInsertAtStart)
End Sub
Show: