Udostępnij za pośrednictwem


How to: Bookmark Code

The Bookmarks window is a handy companion tool to the Code Editor. You can mark lines in your code files with bookmarks and then organize these bookmarks into virtual folders. This enables you to open files and navigate directly to the lines marked simply by clicking entries in the Bookmarks window.

Common procedures for using bookmarks appear below. For information on creating and removing bookmarks in Brief editor mode, see How to: Use Bookmarks with Brief Emulation.

In most Visual Studio programming languages, you can also create Task List shortcuts and comments. As with bookmarks, you can click on any entry in the Task List to open a file and jump to the line of code marked. For more information, see How to: Use Task List Shortcuts and How to: Create Task List Comments.

To create or remove a bookmark using the Bookmarks window

  1. Open a source code file for editing in the Code Editor.

  2. Place the insertion point on the line of code you want to bookmark.

  3. On the View menu, select Bookmark Window.

    The Bookmarks window is displayed. It can be docked along any convenient edge of the IDE. The list of bookmark entries includes an entry for the newly bookmarked line in the active document.

  4. Click the Toggle a bookmark button in the Bookmarks window.

    A bookmark token appears in the Indicator margin of the Code Editor next to the selected line. Click the button again to remove the bookmark.

To create or remove a bookmark using the Text Editor toolbar

  1. Open a file in the Editor.

  2. Place the insertion point on the line you want to bookmark.

  3. On the View menu, select Toolbars and choose Text Editor.

    The Text Editor toolbar is displayed.

  4. Click the Toggle a bookmark button on the Text Editor toolbar.

    A bookmark token appears in the Indicator margin of the Editor window next to the selected line. Click the button again to remove the bookmark.

To jump to a bookmarked line

  1. If the bookmarked file is stored under source code control, check out the file.

  2. Click any bookmark entry in the Bookmarks window.

    The file indicated opens in the Editor and scrolls to the bookmarked line.

  3. On the Text Editor toolbar, the Move the caret to the previous bookmark and Move the caret to the next bookmark buttons are enabled. In the Bookmarks window, the Go to previous bookmark and Go to next bookmark buttons are enabled.

    Click these buttons to navigate to bookmarks in files within the current solution or project.

To organize bookmarks into folders

  1. In the Bookmarks window, click the New Folder button.

    A virtual folder is added to the Bookmarks window.

  2. Drag existing bookmark entries into the added folder.

  3. Select and expand the added folder.

    The Go to previous bookmark in folder and Go to next bookmark in folder buttons are enabled.

  4. Click these buttons to cycle through the bookmarks stored within that folder.

    As each bookmark entry is selected, the file indicated opens in the Editor and scrolls to the bookmarked line.

To change the keyboard shortcut that opens the Bookmarks window

  1. On the Tools menu, choose Options. Expand the Environment folder, and select Keyboard.

    The Keyboard, Environment, Options Dialog Box is displayed.

  2. Select the desired Keyboard mapping scheme.

  3. In the Show Commands containing text box, type the View.BookmarkWindow command.

  4. Click in the Press Shortcut key(s) text box, press the desired shortcut keys, and click Assign.

See Also

Tasks

How to: Navigate Code and Text

How to: Go To a Line of Code

Concepts

Editor Convenience Commands and Features

Reference

Code and Text Editor

Task List (Visual Studio)

Other Resources

Setting Bookmarks in Code

Finding and Replacing