Is there a way to bookmark code in a Visual Studio project?

Visual Studio

Visual Studio Problem Overview


In various projects there are certain parts I will keep jumping to. Is there a way to effectively "bookmark" these parts, so I can quickly jump back to a certain line in a certain file (or a certain method)?

I keep getting lost navigating the solution or doing a "find in whole project/solution".

Visual Studio Solutions


Solution 1 - Visual Studio

In Visual Studio, you can set Bookmarks in the code.

To jump between Bookmarks:

Ctrl + K + N (for next)

and

Ctrl + K + P (for previous)

To toggle a Bookmark on/off for a line:

Ctrl + K + K

Solution 2 - Visual Studio

Yes, press the hotkey combination Ctrl + K + K (that's Ctrl and K, followed by another K) to toggle a bookmark.

Then you can do Ctrl + K + N for the next bookmark and Ctrl + K + P for the previous bookmark.

It works like a charm!

Solution 3 - Visual Studio

With ReSharper, there's a more flexible way of making bookmarks and navigating to them.

You can press Ctrl + Shift + Number for example 3. And then refer to that by Ctrl + 3.

Solution 4 - Visual Studio

I could use the TODO feature, adding my own custom prefix of "BOOKMARK", or "BM" if I'm going to be lazy.

MSDN Documentation For Custom Tags

Solution 5 - Visual Studio

Recent versions of Visual Studio (at least from Visual Studio 2010) have all the comfort for bookmarking. Here is my workflow:

First, you should remember two shortcuts, Show Bookmark Window and Toggle Bookmark. In my setup it is Ctrl + W + B and Ctrl + B + T respectively.

Second, set the Bookmark window to autohide. That step was important for me to finally make bookmarking easy and comforting.

That's how I use bookmarks:

When I am in a position of interest, I Toggle Bookmark and Show Bookmark Window, then press F2 and rename entry — using reasonable names is very helpful for easy navigation.

When I want to get to another position of interest, I Show Bookmark Window, navigate to needed entry, press enter, and voila, I am there.

For me, discovering autohide of a bookmark window was cricial: it allows to quickly get the full view of points of interest, and then it leaves and returns focus to the editor.

Solution 6 - Visual Studio

There is also shortcuts: Ctrl-K, Ctrl-H - sets or removes a shortcut in the tasklist to the current line.

List of all the shortcuts you can see in Task List window. To open it click View - Task List in menu or press Ctrl-\, T. In that window you can select User Tasks, Shortcuts or Comments (not in VS2015).

Visual Studio 2015 bookmarks and shortcuts

Solution 7 - Visual Studio

I too was looking for a better solution to this, having moved from the Delphi 7 IDE to Visual Studio 2010 recently. This comment wonders whether there might be a plug-in that does this and that directed me to the Extension Manager & a search for Bookmark brought up DPack.

I think this gives the OP exactly what he is looking for, particularly when taking this comment of his into account.

Note: Once installed I had to edit the keyboard mappings via Tools | Options | Environment | Keyboard. I put DPack into the Show commands containing edit box, and then scrolled down to find the GoToBookmark[x] and ToggleBookmark[x] that were not working for me and assigned them using the Press shortcut keys edit box. (Make a note of what the "Shortcut [is] currently being used by" before you do this, though; I wouldn't want you to overwrite a function that you don't realize you use extensively!)

Solution 8 - Visual Studio

Visual Studio Bookmarks are a great productivity boost. Click on "View, Bookmarks" (Ctrl K, Ctrl W), you can group your Bookmarks by category - just create a folder, and drag related bookmarks into the folder. They can all be enabled/disabled with one click.

This comes in real handy if you are working on two or more sets of problems concurrently, and you don't want to be schlepping through Enhancement A's book marks while focusing on Bug B. Simply group each problem's set of bookmarks in their respective folders, and you can (de)activate them with one click.

Also, if there are certain places where you have to go back often, simply create a disabled bookmark, and jump directly there through the Bookmark window.

Here is an example:

enter image description here Visual Studio named bookmarks

Solution 9 - Visual Studio

Go to View | Toolbars and check the Text Editor toolbar so it shows up. It has toolbar buttons to Toggle (create/delete) a bookmark on the current line Ctrl-B, T, as well as navigation to the next/prev bookmark, where the navigation is scoped to the solution, folder, or document, depending on which button you use.

Once you have a bookmark created, go to View | Other Windows and select the Bookmark Window (or just press Ctrl-W, B). That will display the list of all the bookmarks. You can double-click any bookmark to jump to it, or use the toolbar button in the Bookmark window for prev/next.

You can also name/rename your bookmarks in the Bookmark window. Right-click on the name and choose rename, or select the name and click it again to enter in to the edit mode.

Solution 10 - Visual Studio

You can install extension: VSBookmarks

Provides up to nine enumerated bookmarks for every text editor tab. All of them are accessible by shortcuts or via a context-menu (right-click and see for VSBookmark submenu).

Ctrl-Shift-[1..9] - set, change or remove a bookmark (you will see an appropriate digit on the left margin of the editor area); Ctrl-[1..9] - go to a previously set bookmark.

enter image description here

Solution 11 - Visual Studio

In Visual Studio 2017 it's

  • Toggle: Ctrl + B, T
  • Enable: Ctrl + B, E
  • Delete all: Ctrl + B, C

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjoshcomleyView Question on Stackoverflow
Solution 1 - Visual StudioJordan ParmerView Answer on Stackoverflow
Solution 2 - Visual StudioMakachView Answer on Stackoverflow
Solution 3 - Visual StudioAli SeyediView Answer on Stackoverflow
Solution 4 - Visual StudiojoshcomleyView Answer on Stackoverflow
Solution 5 - Visual StudioStas BushuevView Answer on Stackoverflow
Solution 6 - Visual StudioVladislavView Answer on Stackoverflow
Solution 7 - Visual StudiolukkeaView Answer on Stackoverflow
Solution 8 - Visual StudioPierreView Answer on Stackoverflow
Solution 9 - Visual StudioThe ToshView Answer on Stackoverflow
Solution 10 - Visual StudioПрофиль заблокированView Answer on Stackoverflow
Solution 11 - Visual StudioBanksySanView Answer on Stackoverflow