264

Visual Studio Code has a hotkey combination to split the current window to 2 or 3 panes:

"key": "ctrl + \",               "command": "workbench.action.splitEditor"

Unfortunately, I can't find a way to switch between such panes without the mouse. My old habit to use F6 does not work either.

Is it supported in Visual Studio Code editor or not?

Josh
  • 1,752
  • 1
  • 18
  • 20
bialix
  • 15,976
  • 8
  • 43
  • 61

14 Answers14

329

https://code.visualstudio.com/docs/customization/keybindings#_editorwindow-management

For Windows: Ctrl+1, Ctrl+2 and Ctrl+3.

For Mac: Cmd+1, Cmd+2 and Cmd+3.

There is no circular switch between panes, similar to what Ctrl+tabs does for files, though.

Pieter Meiresone
  • 1,516
  • 1
  • 17
  • 21
bialix
  • 15,976
  • 8
  • 43
  • 61
  • 26
    there actually is a key binding to cycle through opening files. According to this [article](https://kaushalsubedi.com/blog/2015/11/08/visual-studio-code-key-bindings-to-make-it-work-like-tab-based-editor/), It's "CMD + SHIFT + [" and "CMD + SHIFT + ]" – simonxy Sep 27 '17 at 22:21
  • 2
    the keys work on Chrome tabs too as I accidentally discovered – jokab May 10 '19 at 23:10
  • 3
    Note: For Mac the Ctrl does not work. The key instead of Ctrl is Cmd – user3245268 Jul 15 '19 at 20:46
  • why would you use ctrl+1 if "CMD + SHIFT + [" and "CMD + SHIFT + ]" exists? – Charlie Parker Jan 24 '20 at 19:55
  • 2
    `Ctrl + Shift + [ / ]` seems to be mapped to code folding and unfolding in my version (1.46). I never changed the defaults.Does this mean they changed the defaults? – shahensha Jun 14 '20 at 21:50
  • @simonxy the key binding you showed cycles through tabs in one pane, but the question is about cycling trough panes – Vivi Dec 28 '20 at 02:04
  • This isn't true, as Shaun Luttin shows below, the action you're looking for is `workbench.action.navigateEditorGroups` (can be found in Keyboard shortcuts by searching or in associated json) – n-smits Apr 07 '21 at 16:21
283

If you're used to working in vim (and/or tmux) and want to move around with ctrl+hjkl

add these to keybindings.json

[
    {
        "key": "ctrl+h",
        "command": "workbench.action.navigateLeft"
    },
    {
        "key": "ctrl+l",
        "command": "workbench.action.navigateRight"
    },
    {
        "key": "ctrl+k",
        "command": "workbench.action.navigateUp"
    },
    {
        "key": "ctrl+j",
        "command": "workbench.action.navigateDown"
    }
]
Dan Andreasson
  • 12,290
  • 5
  • 25
  • 28
  • 27
    Can't upvote this enough. Thanks!! This is EXACTLY what I was looking for. – dojosto Jun 08 '18 at 17:50
  • 10
    Give this guy a raise – jaydel Dec 12 '18 at 14:10
  • 2
    Thank you for this. I had already searched through the keybindings without any luck. It seems like the terms "focus" and "navigate" aren't consistently used. – xthrd Jan 14 '19 at 18:40
  • 6
    Thanks for this! In case it helps anyone, I just discovered it breaks VsCodeVim's `Ctrl`+`x` line completion (probably amongst other things) so it felt sensible to disable these shortcuts in insert mode: `"when": "vim.mode != 'Insert'"` – c24w Jan 28 '19 at 15:57
  • 1
    Champ! Really dislike leaving Vim but tooling for Flutter and Dart in Vim just isn't quite there yet so VSCode it is for now. – Jeremy Hindle Feb 09 '19 at 18:56
  • 19
    In case you are trying to figure out how to actually edit `keybindings.json` - see helpful doc here: https://code.visualstudio.com/docs/getstarted/keybindings#_advanced-customization – mgarabed Apr 16 '19 at 14:14
  • Why isn't this answer at the top? I almost miss it – Emilio Bool May 12 '19 at 07:39
  • 1
    @EmilioBool interesting enough, this suggestion does not let one (at least for me) cycle between left/right terminals like `workbench.action.terminal.focusNextPane` allows. Yet it allows to cycle up and down between "code" and terminal panes. – petobens May 13 '19 at 20:06
  • Works perfectly! I've been missing this since moving from VIM to VSCode. – user347480 Nov 16 '19 at 22:24
  • 1
    This is nearly perfect, but for example I can't go from the "Find" text field to the search results with . I made my own config that can do this and a couple of more things (like using to cycle through IntelliSense suggestions). lmk if anybody's interested – Max Coplan Feb 14 '20 at 22:55
  • this is what i need. FYI might be worth adding for Mac, replace control with cmd – Spcogg the second May 31 '20 at 21:59
  • @petobens same here. Would be very cool if it would work with split terminals as well. Does somebody know how to incorporate this? – Jonas Pirner Nov 04 '20 at 08:08
  • 1
    This is a great addition, don't get me wrong, and sorry to be pedantic, but... it's not actually the correct answer! @bialix has the correct answer with the `cmd/ctrl+1` etc shortcuts that come out of the box. This answer is very helpful and I will use it myself, but if it gets voted higher than then other one, which has almost happened, it risks obscuring the real answer which people who *aren't* familiar with `vi` or `tmux` could miss... this a problem with stackoverlflow, not the answer. One for SO meta? – drkvogel Nov 05 '20 at 14:51
  • 1
    Thanks for your excellent answer. I personally use a variation on this to replicate my tmux/vim setup, with a ctrl + space default prefix in tmux. Simple difference: map the above to their respective ctrl + space + [h, j, k, l] chord. Then press ctrl + space and your movement key. Kind of gives a vim-like mode for moving around. – Jason R Stevens CFA Dec 10 '20 at 22:28
102

Use F6 to Cycle Between Editor Groups

There is a circular switch between panes. It's called "Cycle Between Editor Groups."

Out of the box, it is unassigned. We can assign it to F6.

  1. Open Visual Studio Code.
  2. Go to File > Preferences > Keyboard Shortcuts.
  3. Add the following entry to keybindings.json.
  4. You do not have to restart code. It already works.

keybindings.json

// Place your key bindings in this file to overwrite the defaults
[
    {
        "key": "f6", 
        "command": "workbench.action.navigateEditorGroups" 
    }
]

Alternatively

Alternatively, use the out of the box window management hotkeys.

  • Ctrl +1 Focus into Left Editor Group
  • Ctrl +2 Focus into Side Editor Group
  • Ctrl +3 Focus into Right Editor Group
  • Ctrl +K Ctrl+Left Focus into Editor Group on the Left
  • Ctrl +K Ctrl+Right Focus into Editor Group on the Right
Shaun Luttin
  • 107,550
  • 65
  • 332
  • 414
  • 3
    Wow, thanks you, I accidentally found something I've been looking for. Ctrl + K + Left (notice no Ctrl on the Left) does View: Move Editor Group Left (workbench.action.moveActiveEditorGroupLeft). Thank you! – John Lee Jun 28 '19 at 22:56
  • This Actually answers the question for me. The other answers are for how to navigate between files. Thank you! – BCza Feb 18 '20 at 13:59
44

For Mac users and the latest VS Code 1.17:

  1. Switching between panes - Cmd+[1,2,3...], where 1,2,3 is the pane number
  2. Cycling between all open files:
  • forward - Cmd+Shift+]
  • backwards - Cmd+Shift+[
Jason Aller
  • 3,391
  • 28
  • 37
  • 36
demisx
  • 5,047
  • 2
  • 37
  • 34
24

Alt+ and Alt+ works out of the box on Windows. It will only switch between split screen panes and it will not reactivate inactive files inside the panes.

Tamás Panyi
  • 415
  • 5
  • 6
19

Another way is to use Ctrl + PageUp/PageDow to switch between panes.

Valdas Stonkus
  • 335
  • 4
  • 10
9

If you mean editor group, here it is.

enter image description here

dextto
  • 294
  • 3
  • 10
  • 1
    Yes! I'm so happy this exists now, no more mouse! – Arthur Maltson Apr 29 '20 at 11:41
  • This should be the most correct answer. As with what @duane mentioned in a comment to another answer, `cmd+Left/Right` goes to the next panel regardless if it's another tab in the same or a different editor group – RexYuan Feb 03 '21 at 19:49
7

What you are looking for is option workbench.action.terminal.focusNextPane:

{ 
  "key": "alt+down",
  "command": "workbench.action.terminal.focusNextPane",
  "when": "terminalFocus"
},
{ 
  "key": "alt+right",
  "command": "workbench.action.terminal.focusNextPane",
  "when": "terminalFocus"
},
Heikki
  • 2,150
  • 14
  • 27
Dmitry Karpov
  • 79
  • 1
  • 1
  • I think those shortcuts are already inside newer versions, and there's also a `focusPreviousPane` option. – Philippe Fanaro Aug 12 '19 at 13:23
  • Personally, I don't even use the `"when": "terminalFocus"` specification, it makes managing the terminals quicker because I don't have to add a shortcut like `Ctrl + \``. – Philippe Fanaro Aug 12 '19 at 13:29
  • Adding { "key": "alt+up", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" } to `alt+down` and removing `terminalFocus` as explanied by @PhilippeFanaro makes it perfect ;) – Matthis Kohli Aug 15 '19 at 06:03
  • I don't know about the new version but my editor did not have his. Switching panes was such a pain. :D Thank you. – Rohan Feb 28 '20 at 02:35
  • My VS Code has these settings by default but when I use them the cursor moves to next pane but as soon as I release the `alt` key the focus is lost and the menu bar gets focused instead (the bar with file, edit, selection, view, go etc, etc... options on the very top) – Sushmit Sagar Apr 26 '20 at 07:38
5

Obviously the best answer is the hidden comment on the top answer. Not sure why there isn't an answer for it:

CMD + SHIFT + [

and

CMD + SHIFT + ]

I am not sure why anyone would use cmd + 1 or its variants.

Charlie Parker
  • 13,522
  • 35
  • 118
  • 206
  • 1
    You'd use `cmd + 1` or it's other variants (`2`, `3`, `4`, etc) because that's how most tabbed applications work. `CMD + SHIFT + ]` treats all the panes like they are sibling tabs on the same window. – germs12 Feb 13 '20 at 13:38
4

Yes, there is a hotkey to switch between split "editor" window panes, if that is what you mean.

It has to be configured though. This is because the command that allows cycling thru editor panes (aka editor groups) has no default keyboard mapping/binding. Open the "Keyboard Shortcuts" menu option and search for workbench.action.navigateEditorGroups . Click the + icon to add/assign a keybinding. I mapped it to Alt+Q because on a qwerty keyboard 'q' is right next to the Tab key. Given that Alt+Tab cycles thru open OS Windows, it seems sort of natural there.

Mark Dalsaso
  • 163
  • 1
  • 8
3

cmd + option + Left/Right Arrows worked for me.

lando2319
  • 1,224
  • 1
  • 12
  • 23
0

Try Option+Tab for switching sequentially, Cmd+ for switching by number and shift+cmd+[ (or ]) switches between tabs across editors

Vivu
  • 261
  • 3
  • 3
0

If none of the above worked for you and you want just a simple ctrl-h to bind to the left pane and ctrl-l to bind to the right pane then do this:

  1. Open up keyboard shortcuts ( Ctrl-k, Ctrl-s )

  2. Do a search for firstEditorGroup and change key binding of workbench.action.focusFirstEditorGroup to ctr-h

  3. Do another search for secondEditorGroup and change key binding of workbench.action.focusSecondEditorGroup to ctr-h

This is a simple setup if you only ever have two editor panes up.

Isaac Pak
  • 2,865
  • 1
  • 30
  • 41
0

The command View: Navigate Between Editor Groups worked for me, on the MacOS version (1.54.3).

Keyboard shorcut

macquack
  • 37
  • 5