1

I am debugging my code and come across a bookmark I set earlier, my bookmarks have nice names, and I would like to know which bookmark this it. The bookmark window is open, and the last bookmark I clicked on is highlighted, but not the one I am on.

How do I ask visualstudio, “What is the name of the bookmark, that is on this line of code?”

My current method is to click each bookmark in turn, in the bookmark window until I get back to the line I was looking at.

(using visual studio 2012, professional)

ctrl-alt-delor
  • 7,506
  • 5
  • 40
  • 52
  • Open the Bookmark Window, you can use the default command Ctrl+W, B, or you can go to View -> Other Windows -> Bookmark Window. – sara Sep 16 '13 at 10:27
  • @sara are you telling be how to open the bookmark window? This is not what I am trying to do. – ctrl-alt-delor Sep 16 '13 at 10:45

1 Answers1

1

There is no command to synchronize Bookmarks window with current cursor position but you can use this macro as a workaround. The macro assumes that the bookmark where the cursor is is enabled and it will enable all bookmarks after run, which may be a problem to your use case.

Sub SyncBookmarksWindow()
DTE.ExecuteCommand ("Edit.EnableAllBookmarks")
DTE.ExecuteCommand ("Edit.EnableBookmark")
DTE.ExecuteCommand ("Edit.NextBookmark")
DTE.ExecuteCommand ("Edit.EnableAllBookmarks")
End Sub

Bind this macro to a keyboard shortcut and sync away.

EDIT: Unfortunately VS2012 does not allow for macros anymore, and you have to create an Add-In. For how-to see another question on this site.

Community
  • 1
  • 1
Dialecticus
  • 16,400
  • 7
  • 43
  • 103
  • I never got to test it (as using vs2012), bit all the enables seem wrong, my suspicion is in line 2. I guess it should say (translated to english) bookmarks.disable_all; bookmarks.enable_at_cursor_if_bookmark_exists; bookmarks.goto_next_enabled; bookmarks.enable_all; – ctrl-alt-delor Sep 16 '13 at 12:19
  • 1
    The word "toggle" is missing from the command name, but the command "Edit.EnableAllBookmarks" actually toggles bookmarks' state. In Visual Studio corresponding menu item is Edit > Bookmarks > Enable All Bookmarks. There is no "Disable All Bookmarks", because the command actually toggles the state. – Dialecticus Sep 16 '13 at 12:24
  • Ok, nice of them (microsoft) to use names that describe what the methods do. – ctrl-alt-delor Sep 16 '13 at 12:35
  • I have tested it with VS2012 and [Visual Commander](http://vlasovstudio.com/visual-commander/) extension and it works. – IvanH Nov 12 '13 at 15:08