Setting Bookmarks


Keyboard:  CTRL + K, CTRL + K (toggle bookmark)
Menu:  Edit -> Bookmarks -> Toggle Bookmark
Command:  Edit.ToggleBookmark
Versions:  2008,2010
Published:  7/5/2010
Code:  vstipTool0047

 

Bookmarks are a pretty cool feature that a lot of people don’t seem to know about.  Essentially, Bookmarks are a way to mark locations in your code.  Unlike tokens (“TODO’s”), Bookmarks are not stored with the source code.  There are numerous ways to set a Bookmark.  The simplest way is to use CTRL + K, CTRL + K to create a single Bookmark:

image

 

When you set a Bookmark it will create a glyph in the Margin and create an entry in the Bookmarks Window:

image

 

The good news is you don’t have to keep the default name that is given for the Bookmark.  Just RIGHT CLICK the entry in the window and choose “Rename”:

image

 

Then put in whatever you want for the name and you are good to go:

image

 

You can continue to use this method or the menu to create Bookmarks.  Another cool way to create Bookmarks is to use the “Bookmark All” (bottom right) button in the Quick Find dialog (CTRL + F):

image

Comments (18)

  1. mtlhardcore says:

    "Bookmarks are pretty cool", ….well they are ok.

    If you work in a team, they don't always work perfectly….

    For example, if a team member has their Project folder on the C drive and another team member has their Project folder on a D drive, then bookmarks will have issues. Bookmark not found.

    Look at your Image at "When you set a Bookmark it will create a glyph in the Margin and create an entry in the Bookmarks Window"  your location is C:WindowsAzure

    Now.. what if you want to work on another system say at home, or clients etc…

    Anyone have a suggestion or workaround ?

    BTW I still use them.

    Have a great day :)

  2. zainnab says:

    Since Bookmarks aren't stored with the source the general consensus is to not use them for team activites but rather use comment tokens ("TODO"'s) instead.  

    Z

  3. No bookmarks menu says:

    In my Visual Studio 2008, I have bookmark options on the text editor, but no bookmarks menu available.

  4. zainnab says:

    Are you saying that you don't see the Bookmarks submenu off the Edit Menu?

  5. dipti says:

    i m nt able to  set bookmarks using edit-> bookmarks…….

    giv me another option plz..nt even ctrl+k is working in ma visual studion 2008

  6. Gireesh says:

    I am using Visual Studio 2010 Express, I am not able to bookmark through menu or no option is available in Toolbar.. though Ctrl+K,Ctrl+K is working, am not able to move from one bookmark to another..  Please give the key shortcut for that..

  7. Gireesh says:

    Ctrl+K,N  and Ctrl+K,P  are shortcuts for moving to next and previous bookmarks.. Thanks..

  8. mat says:

    ….am not able to bookmark through menu or no option is available in Toolbar….

    you need to change

    tools  >settings > basic settings X

    to

    tools > settings > expert settings X

    then you will be able to see the bookmarks menus and toolbar

  9. Les says:

    Another cool tip would be suggestions on how to replace the glyph used for bookmarks with something that stands out a little more.  Is there an image file that can be replaced?

  10. zainnab says:

    Hey Les :)

    Sadly no.  There currently is no way I am aware of to replace the glyph for bookmarks.

    Z

  11. Rhys Drummond says:

    Numbered bookmarks would be really nice, e.g., Ctrl-K,Ctrl-K,1 then go back to that one with Ctrl-K,Ctrl-N,1.  Easy for 0..9.

    Not as easy as the single keystroke solution Embarcadero offers but still nice.

  12. zainnab says:

    Rhys,

    Yeah I would definitely like to see more work done on the usability of bookmarks.  I think they offer much more than people realize and can be a powerful piece of the experience.

    Z

  13. Saribro says:

    Are bookmarks supposed to save on close (or in any other fashion)?

    I've tried using bookmarks, but every time I restart VS(2008), the bookmark window is empty again. I'd love to use them systematically, but without saving, they're utterly useless :/.

  14. Michael says:

    Why don't you just use relative paths for the bookmarked code? It could be relative to the .sln file, so everyone could use it, no matter if you have your code on drive C: or D: or whereever.

  15. zainnab says:

    Hey Michael,

    I honestly don't know why relative paths aren't used. It makes sense to use them (or at least have an option to use them).

    Z

  16. tlhIntoq says:

    The biggest issue with bookmarks is they are linked to line number, not lines of code like a breakpoint. So if you place a bookmark, then add code above it the bookmark is no longer at the same code you were trying to mark.  Bloody worthless in the real world like this and MS has closed 3 bug reports as "won't fix" because they don't think its a bug.  If breakpoints can drive with the line of code and not pin to the line number, then so can bookmarks if they wanted them to.  They just don't want to.  I liked the idea of comments.  So I defined a comment of //Bookmark: as that will stay with code and is searchable etc.

  17. AFDBAF says:

    I have installed Visual Basic Express 2010 with hotfix ENU KB2635973 and ENU service pack 1 KB983509 (Visual Studio 2010 version 10.0.402191.1 SP1Rel).

    a) The Bookmarks icons are located in the Text Editor toolbar. There are 4 Bookmarks icons:

    a1) Toggle a bookmark on the current line (Ctrl+K,T)

    a2) Move the caret to the previous bookmark (Ctrl+K,P)

    a3) Move the caret to the next bookmark (Ctrl+K,N)

    a4) Clear all bookmarks in all files (Ctrl+K, Ctrl+L)

    b) To access to Text Editor toolbar with the Bookmarks icons:

    b1) Tools menu –> Settings –> check Expert Settings

    b2) View menu –> Toolbars –> check Text Editor

    Note: If in Tools menu –> Settings –> the Basic Settings is checked, then the Text Editor does not have Bookmarks icons.

    c) The Bookmarks are linked to lines of code like a breakpoint, not to line number. So if I place a bookmark, then add or delete code above it, the bookmark stays at the same code I marked.

    d) The Quick Find dialog has a Bookmark All button.

    d1) This button is enabled for Current Document, All Open Documents, and Current Block.

    d2) This button is disabled for Current Project and Entire Solution.

    e) After saving, closing, and reopening the project, the bookmarks are not lost. They stay in the same place I have marked them.

    f) After moving the project to a diferent folder in a different drive, the bookmarks are not lost, and they stay in the same place I have marked them.

    (E.g.: I moved the project from C:UsersAFDBAFDocumentsVisual Studio 2010ProjectsTest_Project to G:Test_Project).

    However

    g) The View menu does not have a Bookmarks window. (Also, the View menu –> Other Windows does not have a Bookmarks window). After looking at all the menus, I did not find a Bookmarks window.

  18. Richard says:

    It will be very useful to add more information than line number (e.g. funciton name) to book mark.