TextSelection Interface

 

Provides access to view-based editing operations and selected text.

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

[GuidAttribute("1FA0E135-399A-4D2C-A4FE-D21E2480F921")]
public interface TextSelection

NameDescription
System_CAPS_pubpropertyActivePoint

Gets the current endpoint of the selection.

System_CAPS_pubpropertyAnchorColumn

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyAnchorPoint

Gets the origin point of the selection.

System_CAPS_pubpropertyBottomLine

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyBottomPoint

Gets the point at the end of the selection.

System_CAPS_pubpropertyCurrentColumn

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyCurrentLine

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyDTE

Gets the top-level extensibility object.

System_CAPS_pubpropertyIsActiveEndGreater

Gets whether the active point is equal to the bottom point.

System_CAPS_pubpropertyIsEmpty

Gets whether the anchor point is equal to the active point.

System_CAPS_pubpropertyMode

Sets or gets a value determining whether dragging the mouse selects in stream or block mode.

System_CAPS_pubpropertyParent

Gets the immediate parent object of a TextSelection object.

System_CAPS_pubpropertyText

Sets or gets the text selection.

System_CAPS_pubpropertyTextPane

Gets the text pane that contains the text selection.

System_CAPS_pubpropertyTextRanges

Gets a TextRanges collection with one TextRange object for each line or partial line in the selection.

System_CAPS_pubpropertyTopLine

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubpropertyTopPoint

Gets the top end of the selection.

NameDescription
System_CAPS_pubmethodBackspace(Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodCancel()

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodChangeCase(vsCaseOptions)

Changes the case of the text selection.

System_CAPS_pubmethodCharLeft(Boolean, Int32)

Moves the object the specified number of characters to the left.

System_CAPS_pubmethodCharRight(Boolean, Int32)

Moves the object the specified number of characters to the right.

System_CAPS_pubmethodClearBookmark()

Clears any unnamed bookmarks in the current text buffer line.

System_CAPS_pubmethodCollapse()

Collapses the text selection to the active point.

System_CAPS_pubmethodCopy()

Copies the text selection to the clipboard.

System_CAPS_pubmethodCut()

Copies the text selection to the clipboard and deletes it from its original location.

System_CAPS_pubmethodDelete(Int32)

Deletes the text selection.

System_CAPS_pubmethodDeleteLeft(Int32)

Deletes a specified number of characters to the left of the active point.

System_CAPS_pubmethodDeleteWhitespace(vsWhitespaceOptions)

Deletes the empty characters (white space) horizontally or vertically around the current location in the text buffer.

System_CAPS_pubmethodDestructiveInsert(String)

Inserts text, overwriting the existing text.

System_CAPS_pubmethodEndOfDocument(Boolean)

Moves the object to the end of the document.

System_CAPS_pubmethodEndOfLine(Boolean)

Moves the object to the end of the current line.

System_CAPS_pubmethodFindPattern(String, Int32, TextRanges)

Searches for the given pattern from the active point to the end of the document.

System_CAPS_pubmethodFindText(String, Int32)

Searches for the given text from the active point to the end of the document.

System_CAPS_pubmethodGotoLine(Int32, Boolean)

Moves to the beginning of the indicated line and selects the line if requested.

System_CAPS_pubmethodIndent(Int32)

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

System_CAPS_pubmethodInsert(String, Int32)

Inserts the given string at the current insertion point.

System_CAPS_pubmethodInsertFromFile(String)

Inserts the contents of the specified file at the current location in the buffer.

System_CAPS_pubmethodLineDown(Boolean, Int32)

Moves the insertion point of the text selection down the specified number of lines.

System_CAPS_pubmethodLineUp(Boolean, Int32)

Moves the insertion point of the text selection up the specified number of lines.

System_CAPS_pubmethodMoveTo(Int32, Int32, Boolean)

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodMoveToAbsoluteOffset(Int32, Boolean)

Moves the active point to the given 1-based absolute character offset.

System_CAPS_pubmethodMoveToDisplayColumn(Int32, Int32, Boolean)

Moves the active point to the indicated display column.

System_CAPS_pubmethodMoveToLineAndOffset(Int32, Int32, Boolean)

Moves the active point to the given position.

System_CAPS_pubmethodMoveToPoint(TextPoint, Boolean)

Moves the active point to the given position.

System_CAPS_pubmethodNewLine(Int32)

Inserts a line break character at the active point.

System_CAPS_pubmethodNextBookmark()

Moves to the location of the next bookmark in the document.

System_CAPS_pubmethodOutlineSection()

Creates an outlining section based on the current selection.

System_CAPS_pubmethodPadToColumn(Int32)

Fills the current line in the buffer with empty characters (white space) to the given column.

System_CAPS_pubmethodPageDown(Boolean, Int32)

Moves the active point a specified number of pages down in the document, scrolling the view.

System_CAPS_pubmethodPageUp(Boolean, Int32)

Moves the active point a specified number of pages up in the document, scrolling the view.

System_CAPS_pubmethodPaste()

Inserts the clipboard contents at the current location.

System_CAPS_pubmethodPreviousBookmark()

Moves the text selection to the location of the previous bookmark in the document.

System_CAPS_pubmethodReplacePattern(String, String, Int32, TextRanges)

Replaces matching text throughout an entire text document.

System_CAPS_pubmethodReplaceText(String, String, Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. Microsoft Internal Use Only.

System_CAPS_pubmethodSelectAll()

Selects the entire document.

System_CAPS_pubmethodSelectLine()

Selects the line containing the active point.

System_CAPS_pubmethodSetBookmark()

Sets an unnamed bookmark on the current line in the buffer.

System_CAPS_pubmethodSmartFormat()

Formats the selected lines of text based on the current language.

System_CAPS_pubmethodStartOfDocument(Boolean)

Moves the insertion point to the beginning of the document.

System_CAPS_pubmethodStartOfLine(vsStartOfLineOptions, Boolean)

Moves the object to the beginning of the current line.

System_CAPS_pubmethodSwapAnchor()

Exchanges the position of the active and the anchor points.

System_CAPS_pubmethodTabify()

Converts spaces to tabs in the selection according to your tab settings.

System_CAPS_pubmethodUnindent(Int32)

Removes indents from the text selection by the number of indentation levels given.

System_CAPS_pubmethodUntabify()

Converts tabs to spaces in the selection according to the user's tab settings.

System_CAPS_pubmethodWordLeft(Boolean, Int32)

Moves the text selection left the specified number of words.

System_CAPS_pubmethodWordRight(Boolean, Int32)

Moves the text selection right the specified number of words.

The properties and methods of the TextSelection object directly reflect editor commands in the Visual Studio integrated development environment (IDE). Like the environment, text selection operations are affected by the editor's global state, such as whether it is in overwrite mode or virtual white space mode.

Any operation attempting to modify a text document fails if it affects any characters contained in a read-only block, or if the text document itself is read-only.

Some of the TextSelection object's properties and methods may fail if the associated document is an HTML document. Possible causes of the failure are: the windows that display the HTML document are not in Source view or the data behind the text document is locked.

Sub TextSelectionExample()
   ' Before running this example, open a text document.
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection
   Dim objActive As VirtualPoint = objSel.ActivePoint
   ' Collapse the selection to the beginning of the line.
   objSel.StartOfLine()
   ' objActive is "live", tied to the position of the actual selection, 
   ' so it will reflect the new position.
   Dim iCol As Long = objActive.DisplayColumn
   ' Move the selection to the end of the line.
   objSel.EndOfLine()

   MsgBox("The length of the insertion point line is " & (objActive.DisplayColumn - iCol) & " display characters.")
End Sub
Return to top
Show: