DEV Community

Discussion on: 14 VS Code Shortcuts to Supercharge Your Productivity

Collapse
leob profile image
leob

Not sure if that's what it's called, but I've (re)defined it like this, in keybindings.json:

{
    "key": "ctrl+up",
    "command": "workbench.action.navigateBack"
},
{
    "key": "ctrl+down",
    "command": "workbench.action.navigateForward"
},
Enter fullscreen mode Exit fullscreen mode

The internal name is "workbench.action.navigateBack" and "workbench.action.navigateForward", and I've assigned "control-up" and "control-down" to it (left and right would have been more logical, but somehow that didn't work).

This is incredibly powerful and I have the impression that not a lot of people know or use it, it's kind of tucked away and doesn't even have default key bindings.

Thread Thread
darrylnoakes profile image
Darryl Noakes

Sorry, I mixed up the two. I found cursor undo/redo in the keybindings menu, and thought it was that. It is like a much more toned-down version of Navigation. It only changes your cursor position, and skips to the beginning of the file if the "history stack" is empty.

Navigation is so much better!, as it navigates between files, and works at all times, not just when an editor is focused.

My VS Code keybindings for Navigation:

  • workbench.action.navigateBack: Alt + LeftArrow (default)
  • workbench.action.navigateForward: Alt + RightArrow (default)
  • workbench.action.navigateToLastEditLocation: Alt + K (default was Ctrl + K, Ctrl + Q)
Thread Thread
leob profile image
leob

Ah nice, I didn't know about the other one, but yeah "navigation" is indeed brilliant because it also navigates backwards/forwards across files ...

Thread Thread
darrylnoakes profile image
Darryl Noakes • Edited on

left and right would have been more logical, but somehow that didn't work

Ctrl + LeftArrow/RightArrow don't work because they are Windows keyboard controls (also in pretty much all OSes). They navigate to the left and right of words.
For example (| represents cursor):
"I am some tex|t." => LeftArrow => "I am some |text."
"I am| some text." => RightArrow => "I am some| text."

Thread Thread
leob profile image
leob

Yeah that's why I chose different key combos for nav prev/next :)