Metodo EditPoint2.DeleteWhitespace (vsWhitespaceOptions)

Elimina orizzontalmente o verticalmente i caratteri vuoti (vuoto) attorno alla posizione corrente nel buffer di testo.

Spazio dei nomi:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Sintassi

'Dichiarazione
Sub DeleteWhitespace ( _
    Direction As vsWhitespaceOptions _
)
void DeleteWhitespace(
    vsWhitespaceOptions Direction
)
void DeleteWhitespace(
    [InAttribute] vsWhitespaceOptions Direction
)
abstract DeleteWhitespace : 
        Direction:vsWhitespaceOptions -> unit 
function DeleteWhitespace(
    Direction : vsWhitespaceOptions
)

Parametri

Note

DeleteWhitespace rimuove lo spazio (vuoto) bianco intorno al punto di modifica o TextSelection senza prima copiare il testo negli Appunti.se Direction viene vsWhitespaceOptionsHorizontal, quindi DeleteWhitespace gli spazi e caratteri di tabulazione elimina da entrambi i lati del punto di modifica all'inizio e alla fine della riga del punto di modifica, o finché uno spazio vuoto non viene rilevato.se Direction viene vsWhitespaceOptionsVertical, quindi DeleteWhitespace le righe vuote elimina da entrambi i lati del punto di modifica all'inizio e alla fine del documento, o fino a una riga non vuoto viene rilevata.se Direction viene vsWhitespaceOptionsVerticale la riga corrente non è vuota, questo metodo non effettua alcuna operazione.

Esempi

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);
        }
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

EditPoint2 Interfaccia

Overload DeleteWhitespace

Spazio dei nomi EnvDTE80

Altre risorse

Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione