删除文本缓冲区中当前位置周围的水平方向或垂直方向的空字符串(空白)。
命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)
语法
声明
Sub DeleteWhitespace ( _
    Direction As vsWhitespaceOptions _
)
void DeleteWhitespace(
    vsWhitespaceOptions Direction
)
void DeleteWhitespace(
    [InAttribute] vsWhitespaceOptions Direction
)
abstract DeleteWhitespace : 
        Direction:vsWhitespaceOptions -> unit 
function DeleteWhitespace(
    Direction : vsWhitespaceOptions
)
参数
- Direction
 类型:EnvDTE.vsWhitespaceOptions
 可选。vsWhitespaceOptions 常数,它确定移除空白的方式和位置。
备注
DeleteWhitespace 移除编辑点或 TextSelection 周围的空白而不用先将文本复制到剪贴板。 如果 Direction 为 vsWhitespaceOptionsHorizontal,则 DeleteWhitespace 删除编辑点两侧的空格和制表符,一直删除到编辑点所在行的行首和行尾,或者遇到非空白字符为止。 如果 Direction 为 vsWhitespaceOptionsVertical,则 DeleteWhitespace 删除编辑点两侧的空行,一直删除到文档开头和末尾,或者遇到非空行为止。 如果 Direction 为 vsWhitespaceOptionsVertical,并且当前行不是空行,则此方法不进行任何操作。
示例
Sub DeleteWhitespaceExample(ByVal dte As DTE2)
    ' Create a new text file.
    dte.ItemOperations.NewFile()
    ' Create an EditPoint at the start of the new document.
    Dim doc As TextDocument = _
        CType(dte.ActiveDocument.Object("TextDocument"), TextDocument)
    Dim point As EditPoint = doc.StartPoint.CreateEditPoint
    Dim i, j As Integer
    ' Insert 10 lines of text.
    For i = 1 To 10
        point.Insert("This is a test." & vbCrLf)
    Next
    If MsgBox("Remove all spaces between words?", MsgBoxStyle.YesNo) _
        = MsgBoxResult.Yes Then
        point.StartOfDocument()
        For i = 1 To 10
            For j = 1 To 3
                point.WordRight()
                point.DeleteWhitespace( _
                    vsWhitespaceOptions.vsWhitespaceOptionsHorizontal)
            Next
            point.StartOfLine()
            point.LineDown()
        Next
    End If
End Sub
public void DeleteWhitespaceExample(DTE2 dte)
{
    // Create a new text file.
    dte.ItemOperations.NewFile(@"General\Text File", "", 
        Constants.vsViewKindPrimary);
    // Create an EditPoint at the start of the new document.
    TextDocument doc = 
        (TextDocument)dte.ActiveDocument.Object("TextDocument");
    EditPoint point = doc.StartPoint.CreateEditPoint();
    // Insert 10 lines of text.
    for (int i = 1; i <= 10; ++i)
        point.Insert("This is a test.\n");
    if (MessageBox.Show("Remove all spaces between words?", "", 
        MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        point.StartOfDocument();
        for (int i = 1; i <= 10; ++i)
        {
            for (int j = 1; j <= 3; ++j)
            {
                point.WordRight(1);
                point.DeleteWhitespace(
                    vsWhitespaceOptions.vsWhitespaceOptionsHorizontal);
            }
            point.StartOfLine();
            point.LineDown(1);
        }
    }
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。