572

How can I set bookmarks in Visual Studio Code? I can't find any keyboard shortcuts.

Or is there anything else that I can use instead?

Gama11
  • 31,714
  • 9
  • 78
  • 100
Rheinprinz
  • 5,816
  • 2
  • 14
  • 11
  • 2
    Looks like Bookmarks is a little more powerful than Numbered Bookmarks. It supports labels, which could do whatever numbering scheme you could ever desire. Also, Numbered Bookmarks appears to be limited to 0-9. – Andrew Sep 17 '19 at 15:46
  • 3
    Bookmarks extension: Ctrl+K+S (or Ctrl+Shift+P to open Keyboard Shortcuts) and search for Bookmarks to assign/change hotkeys. Also nice: it adds a new tab to the left side so you can view your bookmarks. They persist between sessions. – Andrew Sep 17 '19 at 16:02
  • 1
    you can press ctrl+- (go back) or ctrl+shift+- (go forward) to move cursor to where it was, works across files. sort of like bookmarks – Muhammad Umer Feb 06 '20 at 07:28
  • 2
    for me ctrl+- and ctrl+shift+- reduce the window zoom level (zoom out). ctrl+k ctrl+q jumps to the last edit location. – guo Dec 01 '20 at 14:27
  • It's Ctrl+Alt+- and Ctrl+Shift+- for me. These commands are in the "Go" menu. – Sergey Feb 08 '21 at 11:21
  • I like Numbered Bookmarks as I am nostalgic for writing in Delphi :) – hum3 Aug 01 '23 at 13:51

8 Answers8

578

Yes, via extensions. Try Bookmarks extension on marketplace.visualstudio.com

Hit Ctrl+Shift+P and type the install extensions and press enter, then type Bookmark and press enter.

enter image description here

Next you may wish to customize what keys are used to make a bookmark and move to it. For that see this question.

Gama11
  • 31,714
  • 9
  • 78
  • 100
Warren P
  • 65,725
  • 40
  • 181
  • 316
  • 3
    Bookmarks now navigate through all files. Numbered bookmarks still miss this important feature. – Rheinprinz Apr 07 '16 at 22:49
  • 2
    Are you asking for it to NOT navigate through all files? If I remember correctly the Bookmarks extension above is not numbered, and the reason I don't want to use Numbered bookmarks is it's just another mental bit of trivia that distracts me. I just want un-numbered ones. You also? Or you are different? – Warren P Apr 09 '16 at 16:06
  • So do Numbered bookmarks offer a different keyboard shortcut per bookmark? – Warren P Apr 15 '16 at 22:32
  • 1
    Yes they do. You can determine maximum 10 bookmarks. But that is enough, for your work context. – Rheinprinz May 05 '16 at 22:21
  • @WarrenP Can you add a reference to the built-in feature? Just searched for this and I'm not seeing bookmarks. Hit F1, typed 'bookmark' and I'm not getting results in VS Code. Searching docs and I'm not seeing it there either. Did they rename? – beavel Apr 02 '17 at 17:22
  • @WarrenP, just to confirm, this is incorrect: "Update: They are now built in (since late 2015).", right? In other words, there is no such thing as built-in bookmarks. Do you mind removing that statement from the answer if it is indeed incorrect? Thanks! – crayzeewulf Apr 04 '17 at 21:01
  • How to navigate through all files? Next/Prev navigates through current file only. Fortunately the extension adds "Bookmarks" section in VS Code Explorer so I can manually switch to another file. Not optimal but useful. – Andrzej Martyna Feb 21 '18 at 15:18
  • Unfolding the file in the Bookmarks section of the Files Bar lists all the bookmarks by line number, with a peek at the line's contents. – Mark Carpenter Jr Apr 13 '18 at 14:42
  • 22
    "Next you may wish to customize what keys are used to make a bookmark and move to it." – It would be great if the **default shortcuts** would be within the readme file. Nothing mentioned, thus useless. – Edit: Found out how to set the bookmark: `CTRL+ALT+K`. `CTRL+ALT+J` to jump to it. – Avatar Jan 17 '19 at 12:01
  • Typing "install extensions" and hitting Enter - check before doing that, disabled all my extensions – TH Todorov Jun 03 '19 at 13:20
  • 1
    the bookmark label (that little blue thing) sits on top of the red breakpoint circle, you can't toggle both... I can put the bookmark one line above (as a hack) but isn't there a more elegant solution? – Itamar Katz Feb 04 '20 at 12:02
  • 30
    Very embarrassing, a most famous code editor with no native bookmark support. – Azghanvi Jan 21 '21 at 10:37
  • On macOS the Command Palette shortcut is Cmd+Shift+P. – Stevoisiak Mar 09 '22 at 16:25
118

You need to do this via an extension as of the version 1.8.1.

  1. Go to View → Extensions. This will open Extensions Panel.

  2. Type bookmark to list all related extensions.

  3. Install


I personally like "Numbered Bookmarks" - it is pretty simple and powerful.

Go to the line you need to create a bookmark.

Click Ctrl + Shift + [some number]

Ex: Ctrl + Shift + 2

Now you can jump to this line from anywhere by pressing Ctrl + number

Ex: Ctrl + 2

Andreas
  • 5,393
  • 9
  • 44
  • 53
Charlie
  • 22,886
  • 11
  • 59
  • 90
  • 4
    One drawback with "Numbered bookmarks" for some use cases is that the bookmarks are per file. Meaning you can't jump to another file using this extension. A feature request to implement this: https://github.com/alefragnani/vscode-numbered-bookmarks/issues/6 – Juha Palomäki Jan 22 '17 at 14:45
  • @Green They do work! Please follow the instructions in the answer. – Charlie Sep 25 '17 at 13:04
  • 10
    Numbered Bookmarks 0.11.0 do supports navigation across the files. In user setting add the line - "numberedBookmarks.navigateThroughAllFiles": "allowDuplicates" – SridharKritha Jan 30 '18 at 11:13
  • best thing ever – Raheel Hasan Feb 07 '18 at 06:21
  • 4
    Note that there are three settings for navigateThroughAllFiles. The "allowDuplicates" option will allow multiple bookmarks of the same number across different files, from what I understand. The "replace" option works much better for me - one set across all files. Nice. – moodboom Jan 19 '19 at 14:09
  • 2
    +1 for Numbered Bookmarks https://marketplace.visualstudio.com/items?itemName=alefragnani.numbered-bookmarks" Great Extension!!! – Aldo Bassanini Jan 27 '20 at 20:06
  • 1
    Thanks for this tip! We've had numbered bookmarks (same hotkeys) in the Delphi IDE since the 90's. At last MS gets with the program. Maybe [Anders Hejlsberg](https://en.wikipedia.org/wiki/Anders_Hejlsberg#At_Microsoft) forget about them when Bill Gates paid him all that money to go to the dark side. – Reversed Engineer Sep 17 '20 at 08:37
  • @SridharKritha This makes this answer so much more potent! – nights Mar 21 '23 at 11:17
26

Both VS Code extensions can be used:

  1. 'Bookmarks'
  2. 'Numbered Bookmarks'

Personally, I'm suggesting: Numbered Bookmarks, with 'navigate through all files' option:

  1. ctrl + Shift + P in VS Code
  2. In newly open field, type: Open User Settings
  3. Paste this key/value: "numberedBookmarks.navigateThroughAllFiles": "allowDuplicates" (allow duplicates of bookmarks),
  4. Or, paste this key/value: "numberedBookmarks.navigateThroughAllFiles": "replace"

NOTE

Either way, be careful with shortcuts (Ctrl+1, Ctrl+Shift+1,..) that are already assigned.

Personally, mine were in 2 conflicts, with:

  1. VS Code shortcuts, that already exists,
  2. Ditto clipboard (I've got paste on each call of bookmark)
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
25

Visual Studio Code currently does not support bookmarks natively. Please add this as feature request to our Git Hub issue list (https://github.com/Microsoft/vscode).

In the meantime there are some ways to navigate around the code based on your navigation history. You can Ctrl+Tab to quickly jump to previously opened files. You can also navigate within your code based on cursor positions using Goto | Back and Goto | Forward.

Martin Brown
  • 24,692
  • 14
  • 77
  • 122
Benjamin Pasero
  • 113,622
  • 14
  • 75
  • 54
  • 2
    The uservoice request became a request for an extension. It is now marked as "done". See my answer for how to install the extension and then set what keyboard shortcuts are used for it. – Warren P Dec 02 '15 at 16:55
11

The bookmarks extension mentioned in the accepted answer conflicts with toggling breakpoints via the margin.

You could do the same with breakpoints and select the debug tab on the left to see them listed. Better yet, use File, Preferences, Keyboard Shortcuts and set (Shift+)Ctrl+F9 to navigate between them, even across files: enter image description here

Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
7

If you are using vscodevim extension, then you can harness the power of vim keyboard moves. When you are on a line that you would like to bookmark, in normal mode, you can type:

m {a-z A-Z} for a possible 52 bookmarks within a file. Small letter alphabets are for bookmarks within a single file. Capital letters preserve their marks across files.

To navigate to a bookmark from within any file, you then need to hit ' {a-z A-Z}. I don't think these bookmarks stay across different VSCode sessions though.

More vim shortcuts here.

Tryer
  • 3,580
  • 1
  • 26
  • 49
5

No extension

As an alternative you can do Ctrl + P as "Go to file" in your workspace and type:

  • partial name of your file and/or extension.
  • type # + any name of method, property, variable, class (symbol) etc.
  • in currently opened file navigate between symbols with @

I found it more convenient than Bookmarks extension. Of course it depends a lot on your naming conventions and how well you know your codebase.

enter image description here

Konrad Grzyb
  • 1,561
  • 16
  • 12
-4

Under the general heading of 'editors always forget to document getting out…' to toggle go to another line and press the combination ctrl+shift+'N' to erase the current bookmark do the same on marked line…

ajaysinghdav10d
  • 1,771
  • 3
  • 23
  • 33
hsmyers
  • 665
  • 7
  • 10
  • Sorry, but this is misleading, ctrl+shift+n creates a new document.. As other people said, there is only possibility with installing extension. – essential Jun 09 '22 at 06:53