How can I navigate back to the last cursor position in Visual Studio Code? – Dev

The best answers to the question “How can I navigate back to the last cursor position in Visual Studio Code?” in the category Dev.

QUESTION:

What is the keyboard shortcut navigate back to the last cursor position in Visual Studio Code?

ANSWER:

I am on Mac OS X, so I can’t answer for Windows users:

I added a custom keymap entry and set it to Ctrl + + Ctrl + , while the original default is Ctrl + - and Ctrl + Shift + - (which translates to Ctrl + ß and Ctrl + Shift+ß on my German keyboard).

One can simply modify it in the user keymap settings:

{ "key": "ctrl+left",  "command": "workbench.action.navigateBack" },
{ "key": "ctrl+right", "command": "workbench.action.navigateForward" }

For the accepted answer I actually wonder 🙂 Alt + / Alt + jumps wordwise for me (which is kind of standard in all editors). Did they really do this mapping for the Windows version?

ANSWER:

The keyboard shortcut commands are Go Forward and Go Back.


On Windows:

Alt + … navigate back

Alt + … navigate forward

On Mac:

Ctrl + - … navigate back

Ctrl + Shift + - … navigate forward

On Ubuntu Linux:

Ctrl + Alt + - .., navigate back

Ctrl + Shift + - … navigate forward

ANSWER:

For macOS:

+ U: Undo the last cursor operation

You can also try Ctrl + -.

BTW, all the shortcuts are in Keyboard shortcuts for macOS. This is really useful!

ANSWER:

This will be different for each OS, based on the information in Key Bindings for Visual Studio Code.

Workbench configuration:

Go Back: workbench.action.navigateBack
Go Forward: workbench.action.navigateForward

Linux:

Go Back: Ctrl+Alt+-
Go Forward: Ctrl+Shift+-

Mac OS X:

Go Back: Ctrl + -
Go Forward: Ctrl + Shift (⇧) + -

Windows:

Go Back: Alt + ⬅️
Go Forward: Alt + ➡️