52

In Visual Studio Code, is there a keyboard shortcut to navigate (move cursor) to the last edited position (like in all Jetbrains products with Ctrl+Shift+Backspace)?

The CTRL+- shortcut moves to the last position (not the last edited position), which is less useful for me.

i am using with Visual Studio Code JetBrains IDE Keymap for Visual Studio Code:

Visual Studio Code Version 1.23.1 Commit d0182c3417d225529c6d5ad24b7572815d0de9ac Datum 2018-05-10T17:11:17.614Z Shell 1.7.12 Renderer 58.0.3029.110 Node 7.9.0 Architektur x64

wisbucky
  • 33,218
  • 10
  • 150
  • 101
SL5net
  • 2,282
  • 4
  • 28
  • 44

3 Answers3

56

Also see https://stackoverflow.com/a/71212026/836330 for new navigation commands in vscode v1.65. See that link for navigating to next/previous cursor locations (where the cursor was but maybe no actual edit there).

For last edited locations:

Go Forward in Edit Locations
"workbench.action.navigateForwardInEditLocations"

Go Back in Edit Locations
"workbench.action.navigateBackInEditLocations"

Go Previous in Edit Locations
"workbench.action.navigatePreviousInEditLocations"

Go to Last Edit Location
      // acts like a toggle between current and last edit location
"workbench.action.navigateToLastEditLocation"

Associated context keys have been added to make assigning keybindings more powerful:

  • canNavigateBackInNavigationLocations: Whether it is possible to go back in navigation locations
  • canNavigateForwardInNavigationLocations: Whether it is possible to go forward in navigation locations
  • canNavigateToLastNavigationLocation: Whether it is possible to go to the last navigation location
  • canNavigateBackInEditLocations: Whether it is possible to go back in edit locations
  • canNavigateForwardInEditLocations: Whether it is possible to go forward in edit locations
  • canNavigateToLastEditLocation: Whether it is possible to go to the last edit location
Mark
  • 143,421
  • 24
  • 428
  • 436
  • that's much better than that was i was looking for – SL5net Jun 01 '18 at 16:47
  • 3
    Cmd+K and Cmd+Q for Mac, but I had to remap them because they were already taken by OS. – Luckylooke Nov 13 '19 at 16:08
  • If you use vim extension, I would recommend to chante the default keybinding for the _Go to Last Edit Location_ command. Bind it with`Alt+Shift+J` instead. Go to _File->Preferences->Keyboard Shortcuts_ or insert in _keybinds.json_ `{ "key": "shift+alt+j", "command": "workbench.action.navigateToLastEditLocation"}` to do it. – nav Jun 08 '20 at 13:36
  • I made it to: { "key": "cmd+shift+backspace", "command": "workbench.action.navigateToLastEditLocation" }, to align with Intellij – karl li Sep 16 '21 at 01:20
  • How to navigate to a **previous** edit location, not only to the last one? – James Bond Feb 03 '22 at 21:24
  • 1
    All of these are not the same thing that exist in Intellij IDE's. In Intellij you can always move through last **N** locations, not only to the latest one. – James Bond May 08 '22 at 11:53
33

For Windows use Alt+RightArrow and Alt+LeftArrow.

nAviD
  • 2,784
  • 1
  • 33
  • 54
  • 10
    Those are for workbench.action.navigateBack and forward not for navigating to last edit. Difference is that by navigating back you are steping trough each view you have visited. Whether to last edit you skip all visited views and jump directly to last edited location which is mostly much more desired :) – Luckylooke Nov 13 '19 at 16:06
  • 14
    For MAC (Navigation): ```Ctrl+-``` navigate back ```Ctrl+Shift+-``` navigate forward – Saurabh Bayani Apr 17 '20 at 13:53
  • @SaurabhBayani you should add an answer I would totally upvote it. thanks – ecoologic Nov 26 '21 at 01:33
  • Alt+RightArrow/LeftArrow walkes open files, not to edit positions here in my Kubuntu v 20.04 – SL5net Jan 27 '22 at 08:41
4

Last Edited Shortcut

Cntrl+k,Cntrl+q

enter image description here

Last Cursor Movement

ALt+Arrow left

enter image description here

lava
  • 6,020
  • 2
  • 31
  • 28