Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

keyboard shortcut for go back to last edited position in Visual Studio Code

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

like image 657
SL5net Avatar asked May 30 '18 15:05

SL5net


People also ask

How do you get to the last position in Visual Studio?

Go to recent files: (Ctrl + T + R) [Ctrl + T to open search box, then type R] Go to last edit location: (Ctrl + Shift + Backspace) [different from navigate backward, which just goes to last cursor location -- this goes to last place where code was edited]

What is Ctrl K in VS Code?

To launch the Define Keybinding widget, press Ctrl+K Ctrl+K. The widget listens for key presses and renders the serialized JSON representation in the text box and below it, the keys that VS Code has detected under your current keyboard layout.

What is Ctrl Shift L in VS Code?

Press Ctrl + Shift + L . This will select all words that match your current selection. It also adds a cursor to each text span matching your current selection. Simply start typing your replacement text and vscode will start replacing all instances of text matching your selection in-editor as you type.


1 Answers

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

[EDIT]: v1.28.0 just added a command to go back to the last edited position, see release notes: navigate back to last edited position.

Navigate to last edit location

A new command Go to Last Edit Location (workbench.action.navigateToLastEditLocation) was added to quickly navigate to the last location in a file that was edited. The default keybinding is

Ctrl+K Cntrl+Q

like image 54
Mark Avatar answered Sep 19 '22 19:09

Mark