Visual Studio 6.0 provides a useful feature to set unnamed bookmarks to mark lines in a file. This is especially useful when going through a large source or log file.
Often times, I would like to disable some unnamed bookmarks, but enable them again later. For a large file and with lots of unnamed bookmarks, remembering the removed unnamed bookmark line numbers can be difficult.
The Edit Breakpoints feature allows breakpoints to be selectively set to inactive and then again to active later. However, this isn't available for unnamed bookmarks. Also, breakpoints in files are restored again if the files are reopened later. This feature also isn't available for unnamed bookmarks.
Another feature which I would like is to save the unnamed bookmarks of a file to a .xml file. I can then use this .xml file to restore the unnamed bookmarks at a later time.
This add-in provides the following features:
- Save and restore unnamed bookmarks (active and inactive) to and from a .xml file.
- Edit unnamed bookmarks (similar to the Edit Breakpoints feature provided by Visual Studio).
- On reopening a closed document, all active and inactive unnamed bookmarks that were set for the file before it was closed are restored.
Using the add-in
Setting up the add-in
Copy the DLL file to a location in your local drive. In Visual Studio, in the Tools menu, select the Customize... menu item. In the Customize dialog that pops up, select the tab "Add-Ins and Macro Files". Use the Browse... button to browse to and select the DLL. "Manage Bookmarks" will appear in the list box. Check its checkbox and close the Customize dialog. The add-in toolbar will appear and the setup is done.
To remove the add-in, in the Customize dialog, uncheck the "Manage Bookmarks" entry in the list box.
The add-in toolbar
The add-in provides a toolbar with three buttons. They are Save bookmarks, Load bookmarks, and Edit bookmarks.
- Save bookmarks prompts for the .xml file name to save all the active and inactive unnamed bookmarks for all open files in Visual Studio.
- Load bookmarks prompts to select the .xml file from which the unnamed bookmarks will be restored.
- Edit bookmarks brings up the Edit Bookmarks dialog. Uncheck or check the checkbox of an item in the list control of the Edit Bookmarks dialog to set an unnamed bookmark to inactive or active, respectively. Setting a bookmark to inactive (uncheck the checkbox in the Edit Bookmarks list) is similar to the feature of using the Edit Breakpoints dialog of Visual Studio to disable a breakpoint.
Restoring unnamed bookmarks on reopening files in Visual Studio
On closing a file which had active and inactive unnamed bookmarks, the bookmarks are remembered, and later reopening the same file again, restores the active and inactive bookmarks. The add-in automatically saves such bookmarks, when Visual Studio closes, to the file "VSBookmarks.xml" in the folder containing the MSDEV.exe (to be found in \Program Files\Microsoft Visual Studio\Common\MSDev98\Bin in your Visual Studio installed drive). To specify a file name and folder different from this, create a system environment variable
VISUAL_STUDIO_BOOKMARKS_FILEPATH and set its value to the full path name of the .xml file to store the bookmarks, for example, C:\myBookmarks.xml.
Known issues and limitations
- The previous selection is not maintained after setting the bookmarks. However, the cursor position is restored to the previous line on which the cursor was present. The scroll position is not maintained, so you will find the cursor on the same line as before editing the bookmarks, but the scroll bar position of Visual Studio may be different.
- Restoring the unnamed bookmarks requires opening the files, so flickering occurs in the file window of Visual Studio since switching between files takes place.
- There is no provision to disable the bookmark saving to a file when Visual Studio closes, and to restore bookmarks on opening files or workspaces.