BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2005+

Visual Studio Bookmarks

When working on large projects you may need to revisit several areas of your code on a regular basis. Rather than manually navigating between files and through code, you can use Visual Studio's bookmarks feature to quickly jump to the desired location.

Bookmarks

Visual Studio includes a feature that allows you to add a bookmark to a line of code in a solution. As with a traditional bookmark that quickly allows you to return to your last reading position in a novel, the Visual Studio variety lets you quickly find a marked line in your code. You can create many bookmarks throughout your projects and quickly navigate between them.

NB: In this article we will examine the features offered by Visual Studio 2005 and later versions of the development environment. Visual Studio 2003 also included bookmark features but these were limited in comparison to those described here.

Creating a Bookmark

To create a bookmark, you must first position the text cursor on the line that you wish to mark. Next, open the Edit menu, select the Bookmarks sub-menu and click "Toggle Bookmark". You can also press Ctrl-K,K to toggle a bookmark. The bookmark appears as a square-shaped glyph in the margin at the left of the code.

Visual Studio Bookmark

Removing Bookmarks

Bookmarks can be removed from your code in several ways. Firstly, you can use the same "Toggle Bookmark" command. If a bookmark already exists for the current line of code, it will be removed. You can remove all of the bookmarks from your project at once using the "Clear Bookmarks" command from the same menu, or by clicking Ctrl-K,L. Finally, you can remove every bookmark from the current file by selecting the "Clear All Bookmarks In Document" option from the menu.

Navigating with Bookmarks

Once you have created several bookmarks, you can jump between them using the navigation commands. Four of the most used commands in the Bookmarks menu are:

  • Next Bookmark (Ctrl-K,N). Jumps to the next bookmark in the project.
  • Previous Bookmark (Ctrl-K,P). Jumps to the previous bookmark in the project.
  • Next Bookmark In Document. Jumps to the next bookmark in the current document.
  • Previous Bookmark In Document. Jumps to the previous bookmark in the current document.

Enabling and Disabling Bookmarks

If you temporarily wish to disable a bookmark but you do not want to clear it permanently, you can disable it using the Enable Bookmark command. This command toggles the status of the bookmark on the current line of code. The glyph changes to indicate that the bookmark is no longer active. Choosing the same command again reactivates the bookmark.

To disable all bookmarks, choose the Disable All Bookmarks command from the menu. When all bookmarks are disabled, the menu item's text changes to "Enable All Bookmarks". This re-enables all of the bookmarks in the project.

Using the Bookmarks Window

The Bookmarks window provides additional features that allow you to name and organise your bookmarks. The window can be displayed by selecting "Bookmark Window" from the View menu. The window is pictured below:

Visual Studio Bookmarks Window

The window provides a toolbar containing various bookmarking commands and shows a list of the currently defined bookmarks, each with a checkbox indicating whether the bookmark is enabled or not. In the image above, you can see that the bookmarks have been given descriptive names. This is achieved by right-clicking an item in the list and selecting "Rename" form the context-sensitive menu that appears.

Bookmark Folders

If you use bookmarks extensively, it can be useful to add an extra level of organisation using bookmark folders. Folders can be created using the New Folder command from the Bookmarks window. Once created, individual bookmarks can be dragged into the folder.

Each bookmark folder is displayed with a checkbox. Clicking this checkbox toggles the enabled status of all of the bookmarks that are contained within the folder.

When your bookmarks are organised into folders, two new navigation commands become useful. These are:

  • Next Bookmark (Ctrl-Shift-K,N). Jumps to the next bookmark in the current bookmark folder.
  • Previous Bookmark (Ctrl-Shift-K,P). Jumps to the previous bookmark in the current bookmark folder.
7 February 2009