Last updated: Apr 6, 2024
Reading time·4 min
To go to the previous or next location in Visual Studio Code:
on Windows:
Alt
+ Left
arrow key to navigate back.Alt
+ Right
arrow key to navigate back.on macOS:
Ctrl
+ -
to navigate back.Ctrl
+ Shift
+ -
to navigate forward.on Linux:
Ctrl
+ Alt
+ -
to navigate back.Ctrl
+ Shift
+ -
to navigate forward.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.
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.You can also access the Go back and Go forward commands via the top menu:
Note that you might have to press Alt
on Windows and Linux to show the top
menu.
The Forward command is only enabled if you have issued the Back command.
If you need to update the keyboard shortcuts for the "Go Back" and "Go forward" commands:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Double-click on the row, set your preferred keyboard shortcut and hit Enter
to confirm.
Type Go forward.
Enter
to confirm.To go to the last edit location:
Ctrl + K
Ctrl + Q
.You first press Ctrl + K
, release the keys and then press Ctrl + Q
.
Cmd + K
Cmd + Q
.You can also use the Command Palette to issue to command or view its keyboard shortcut:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.You can also view other similar commands if you type go edit in the Command Palette.
If you need to change the keyboard shortcut for the "Go to Last Edit Location" command:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Enter
to confirm.You can learn more about the related topics by checking out the following tutorials: