This documentation is archived and is not being maintained.

DeleteWhitespace Method (General Extensibility)

Visual Studio .NET 2003

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

[Visual Basic .NET]
Public Sub DeleteWhitespace( _
   Optional ByVal Direction As vsWhitespaceOptions = vsWhitespaceOptionsHorizontal _
) 
[Visual Basic 6]
Sub DeleteWhitespace( _
   Optional ByVal Direction As vsWhitespaceOptions = vsWhitespaceOptionsHorizontal _
) 
[C++]
HRESULT __stdcall DeleteWhitespace(
   vsWhitespaceOptions Direction
);
[C#]
void DeleteWhitespace(
   vsWhitespaceOptions Direction
);
[JScript .NET]
public function DeleteWhitespace(
   Direction : vsWhitespaceOptions
)

Parameters

Direction
Optional. A vsWhitespaceOptions constant that determines how and where to remove empty spaces.

Remarks

DeleteWhitespace removes white (empty) space around the edit point or TextSelection without first copying the text to the clipboard. If Direction is vsWhitespaceOptionsHorizontal, then DeleteWhitespace deletes spaces and tab characters on both sides of the edit point to the beginning and end of the edit point's line, or until a non-white-space character is encountered. If Direction is vsWhitespaceOptionsVertical, then DeleteWhitespace deletes blank lines on both sides of the edit point to the beginning and end of the document, or until a non-blank line is encountered. If Direction is vsWhitespaceOptionsVertical, and the current line is not blank, then this method does nothing.

Example

Sub DeleteWhitespaceExample()
   Dim objTextDoc As TextDocument
   Dim objEditPt As EditPoint, iCtr As Integer
        
   'Create a new text file.
   Call DTE.ItemOperations.NewFile("General\Text File")
       
   'Get a handle to the new document and create an EditPoint.
   objTextDoc = DTE.ActiveDocument.Object("TextDocument")
   objEditPt = objTextDoc.StartPoint.CreateEditPoint
        
   'Insert ten lines of text.
   For iCtr = 1 To 10
     objeditpt.Insert("This is a test." & Chr(13))
   Next iCtr
       
   objEditPt.StartOfDocument()
   objEditPt.WordRight(2)
   'Remove the spaces between the words.
   objEditPt.DeleteWhitespace(vsWhitespaceOptions.vsWhitespaceOptionsHorizontal)
End Sub

See Also

EditPoint Example 1

Applies To: EditPoint Object | TextSelection Object

Show: