Export (0) Print
Expand All

EditPoint.PreviousBookmark Method

Moves the edit point to the location of the previous bookmark in the document.

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

bool PreviousBookmark()

Return Value

Type: System.Boolean
A Boolean value indicating true if the edit point moves to a previous bookmark, false if not.

If there are no more bookmarks, the edit point is not moved.

PreviousBookmark moves the EditPoint object to the location of the first bookmark preceding the location of the active end of the EditPoint. The EditPoint is collapsed at the new location.

public void PreviousBookmarkExample(DTE2 dte)
{
    // Create a new text document.
    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 ten lines of text.
    for (int i = 1; i <= 10; ++i)
        point.Insert("This is a test.\n");

    point.StartOfDocument();

    // Set a bookmark on each of the first two lines.
    point.SetBookmark();
    point.LineDown(1);
    point.SetBookmark();

    // Insert text at each bookmark and then clear each bookmark.
    point.PreviousBookmark();
    point.Insert("BOOKMARK 1: ");
    point.ClearBookmark();
    point.NextBookmark();
    point.Insert("BOOKMARK 2: ");
    point.ClearBookmark();
}

Show:
© 2015 Microsoft