69

I started using Visual Studio Code today (I've been using Atom and Sublime for years).

In Atom/Sublime (and Chrome, Firefox, etc...) you can go to another open tab with CMD + a number. Is it possible to get that behavior in VSC? (Mac)

Right now "CMD + 2" just splits the file in two columns and I do not need that at all.

Rickety
  • 754
  • 6
  • 10

2 Answers2

132

Yeah this is possible.

File -> Preferences -> Keyboard Shortcuts -> Click keybindings.json (document icon with an rounded arrow coming out of the left side)

{ "key": "cmd+1","command": "workbench.action.openEditorAtIndex1" },
{ "key": "cmd+2","command": "workbench.action.openEditorAtIndex2" },
{ "key": "cmd+3","command": "workbench.action.openEditorAtIndex3" },
{ "key": "cmd+4","command": "workbench.action.openEditorAtIndex4" },
{ "key": "cmd+5","command": "workbench.action.openEditorAtIndex5" },
{ "key": "cmd+6","command": "workbench.action.openEditorAtIndex6" },
{ "key": "cmd+7","command": "workbench.action.openEditorAtIndex7" },
{ "key": "cmd+8","command": "workbench.action.openEditorAtIndex8" },
{ "key": "cmd+9","command": "workbench.action.openEditorAtIndex9" }
lejlun
  • 4,140
  • 2
  • 15
  • 31
Ed Heltzel
  • 1,679
  • 1
  • 13
  • 9
  • 5
    Crazy that you have to do this, but it works like a charm. I added this right after my bindings for `{ "key": "cmd+shift+[", "command": "workbench.action.previousEditor" }, { "key": "cmd+shift+]", "command": "workbench.action.nextEditor" }, ...` – SilverSideDown Dec 22 '16 at 14:47
  • 18
    I changed `cmd+9` to `"command": "workbench.action.openLastEditorInGroup"`, so it opens the last tab open, just like in other applications on macOS – jonathanGB Oct 29 '17 at 01:19
  • 23
    As of VSCode 1.25, the command `"workbench.action.openLastEditorInGroup"` changed to `"workbench.action.lastEditorInGroup"` per https://code.visualstudio.com/updates/v1_25#_removed-commands – Irving Aug 27 '18 at 17:49
  • 5
    Works great. Note that "Click keybindings.json" is performed by clicking the **{}** button on the top right of the Keyboard Shortcuts title bar (for those not familiar with it, like me). – talarczykco Jun 29 '19 at 13:35
  • 2
    Now the feature that I want is these numbers to still work across panes. It seems that if you have two open panes, VScode has separate indexes for each pane. – Our_Benefactors Jul 15 '19 at 19:25
  • In case people don't know: alt+1, alt+2, etc. has been in vscode for some time to switch between tabs. But if you want to use cmd use the answer above. – Mark Jan 11 '20 at 13:55
  • 4
    "For those of you looking for the {} it now looks like a document icon with an rounded arrow coming out of the left side. A shame their documentation fails to mention this." (From this comment: https://stackoverflow.com/questions/33791097/how-can-i-change-keyboard-shortcut-bindings-in-visual-studio-code#comment101563575_33791170) – tuomassalo Aug 13 '20 at 19:32
  • 1
    Ah yes, the "turn piece of paper over to see the JSON on the other side" icon. – Charlie Schliesser Sep 24 '21 at 14:48
6

The answer from Ginfuru above still works fine, but if you want more things in VSC to behave like Atom, I can also recommend this extension: Atom Keymap, that ports popular Atom keyboard shortcuts to VSC.

Rickety
  • 754
  • 6
  • 10