VS Code: Go to previous location or to last Edit location

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
4 min

banner

# Table of Contents

  1. Got to the previous or next location in VS Code
  2. Updating the keyboard shortcuts for the Go Back and Go Forward commands
  3. Go to the Last edit location in VS Code
  4. Changing the Keyboard shortcut for the "Go to last Edit Location" command

# Got to the previous or next location in VS Code

To go to the previous or next location in Visual Studio Code:

  • on Windows:

    • Press Alt + Left arrow key to navigate back.
    • Press Alt + Right arrow key to navigate back.
  • on macOS:

    • Press Ctrl + - to navigate back.
    • Press Ctrl + Shift + - to navigate forward.
  • on Linux:

    • Press Ctrl + Alt + - to navigate back.
    • Press Ctrl + Shift + - to navigate forward.

go to previous or next location

The Go Back command returns you to the previous position of your cursor.

The Go Forward command can be used once you have issued the Go Back command to navigate forward to the next position of your cursor in the stack.

You can also view the keyboard shortcuts for the Go Back and Go Forward commands for your operating system in this table in the docs.

An alternative way to find the keyboard shortcut is to use the Command Palette.

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type go back and view the keyboard shortcut for the Go Back command.

view go back command shortcut

You can also access the Go back and Go forward commands via the top menu:

  1. Click on Go in the top menu.
  2. Click on Back or Forward.

Note that you might have to press Alt on Windows and Linux to show the top menu.

access go back forward using top menu

The Forward command is only enabled if you have issued the Back command.

# Updating the keyboard shortcuts for the Go Back and Go Forward commands

If you need to update the keyboard shortcuts for the "Go Back" and "Go forward" commands:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type Keyboard Shortcuts and select Preferences: Open Keyboard Shortcuts.

preferences open keyboard shortcuts

  1. Type Go back.

set custom keyboard shortcut for go back command

  1. Double-click on the row, set your preferred keyboard shortcut and hit Enter to confirm.

  2. Type Go forward.

set custom keyboard shortcut for go forward command

  1. Double-click on the row, set your preferred keyboard shortcut and hit Enter to confirm.

# Go to the Last edit location in VS Code

To go to the last edit location:

  • on Windows and Linux: press Ctrl + K Ctrl + Q.

You first press Ctrl + K, release the keys and then press Ctrl + Q.

  • on macOS: press Cmd + K Cmd + Q.

go last edit location

You can also use the Command Palette to issue to command or view its keyboard shortcut:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type go to last edit and select the Go to Last Edit Location command or view its keyboard shortcut.

view go last edit location keyboard shortcut

You can also view other similar commands if you type go edit in the Command Palette.

view other similar commands

# Changing the Keyboard shortcut for the "Go to last Edit Location" command

If you need to change the keyboard shortcut for the "Go to Last Edit Location" command:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type Keyboard Shortcuts and select Preferences: Open Keyboard Shortcuts.

preferences open keyboard shortcuts

  1. Search for wrap with abbreviation and double-click on the option.

set custom keyboard shortcut for go to last edit command

  1. Double-click on the row, set your preferred keyboard shortcut and hit Enter to confirm.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.