Robust solution to manage programmatically Visual Studio Bookmarks ?


  • I am trying to generate bookmarks in the Bookmark Window.

    At first I tried to create an add-in. As I cannot find a BookmarkWindow object in the DTE2 interface, I tried to use commands such as:

    As the BookmarkWindow.Rename command does not seem to accept arguments,  I tried to use the SendKeys.SendWait() method to set the bookmark name.

    This works well enough when my command is called from the Tools menu, however it fails horribly when calling from a keyboard shortcut (which, sadly, is my purpose).

    I then converted my add-in into a VSPackage, therefore I have access I believe to more extension functions. However I still do not find how to interact with the Bookmarks Window. Which should I look at?

    Tuesday, October 22, 2013 8:49 AM

All replies

  • Hi _wil_,

    I think you can use SVsCommandWindowsCollection Interface. You may need the method OpenExistingOrCreateNewCommandWindow.

    IVsCommandWindowsCollection::OpenExistingOrCreateNewCommandWindow Method : Opens an existing command window or creates a new one.

    int OpenExistingOrCreateNewCommandWindow(
    	[InAttribute] unsigned int mode, 
    	[InAttribute] int fShow, 
    	[OutAttribute] unsigned int% puCookie


    Type: System::UInt32

    [in] A value of type __COMMANDWINDOWMODE2.

    Type: System::Int32

    [in] Specifies if the command window should be visible when opened or created.

    Type: System::UInt32%

    [out] A cookie for the command window. Use when closing the window with Close.and in other methods of this interface.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 23, 2013 11:01 AM
  • Did you ever figure this out?! I am trying to do something very similar and having the same problems. Can't believe Visual Studio doesn't just let us set the bookmark name without these backdoors.
    Tuesday, May 13, 2014 4:45 AM
  • Hi Anna, thank you for the reply.

    Are you suggesting me to use the IVsCommandWindow.ExecuteCommand method with the "OtherContextMenus.BookmarkWindow.Rename" command?

    Then will I be able to pass the string I want to rename my bookmark to as well? I cannot test it right now.

    Tuesday, May 13, 2014 5:33 AM
  • Hi Nathan,

    I did not investigate the method suggested by Anna Cc yet. 

    For the time being, I am still using the DTE2 interface and SendKeys.SendWait()

    If you want to give this method a try, you can get the extension here at visualstudiogallery.

    I would be interested if you happened to find a better way to rename Visual Studio bookmarks.

    Tuesday, May 13, 2014 5:42 AM
  • I briefly researched and played with the SVsCommandWindowsCollection class, but didn't see how I could send arguments to that rename field. I would be greatly interested in a better solution as well, since if I don't get this working as needed, I will be forced to "reinvent the wheel" by creating a whole new Bookmarking window, like this plug-in "Numbered Bookmarks". Anyways, thanks so much for sharing your code! I'm still relatively new to Visual Studio but have found the community is great and I'm looking forward to giving back as much as I can.

    Tuesday, May 13, 2014 6:02 AM
  • Thank you for the feedback.

    There are indeed several plug-ins with features similar to Visual Studio bookmarks, but I never found one that perfectly matched my needs. I personally tried to use one called Favorite Documents for a while.

    Wednesday, May 14, 2014 2:23 AM