Rheinprinz
Rheinprinz

Reputation: 6756

Are bookmarks supported in Visual Studio Code?

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?

Upvotes: 666

Views: 259681

Answers (10)

Cees Timmerman
Cees Timmerman

Reputation: 19644

The Bookmarks extension mentioned in the accepted answer used to (until April 2023) conflict with toggling breakpoints via the margin.

Alternative (breakpoints)

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

Alternative (shortcuts)

If you just want to switch between recent views (even across files) without using Split Editor (Ctrl+ \ ), try Alt+Left/Right for Back/Forward and (Shift+)Alt+F5 for Next/Previous Change on Windows.

Upvotes: 17

Charlie
Charlie

Reputation: 23778

You can only do this using an extension (as of version 1.92).

  1. Go to View → Extensions. This will open the Extensions view.

  2. Type bookmark to list all related extensions.

  3. Install


I personally like "Numbered Bookmarks", which is pretty simple and powerful.

  1. Go to the line you need to bookmark.
  2. Press Ctrl + Shift + some digit
    Ex: Ctrl + Shift + 2

Now you can jump to this line from anywhere by pressing Ctrl + digit
Ex: Ctrl + 2

Upvotes: 137

Adrian Stanisławski
Adrian Stanisławski

Reputation: 745

Not a bookmark but something kind of similar - in the code you can put

//MARK: Something

Thanks to that you will have a label on a slider: enter image description here

Upvotes: 2

dkamins
dkamins

Reputation: 21918

Not a direct answer, but a very useful partial solution and good keyboard shortcut to know:

Look at the top of the "Go" menu and you will see "Back" and "Forward". Usually ctrl+- and ctrl+shift+- or ctrl+alt+- or something similar.

Use these like navigating a browser history of cursor positions, across files.

Upvotes: 1

Warren  P
Warren P

Reputation: 68892

Support for bookmarks can be enabled 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.

Upvotes: 640

Konrad Grzyb
Konrad Grzyb

Reputation: 1985

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

Upvotes: 13

Tryer
Tryer

Reputation: 4050

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.

Upvotes: 8

Djordje Stefanovic
Djordje Stefanovic

Reputation: 419

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)

Upvotes: 29

hsmyers
hsmyers

Reputation: 711

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…

Upvotes: -6

Benjamin Pasero
Benjamin Pasero

Reputation: 123794

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.

Upvotes: 25

Related Questions