SoftTimur
SoftTimur

Reputation: 5490

Shortcut to switch between 2 VSCode windows when there are several VSCode windows opened

I'm using a Mac.

I have several VSCode windows opened.

I would like to switch between only 2 (last viewed) windows. Does anyone know what is the keyboard shortcut to do so?

I tried command + `, but it went through all the opened VSCode windows one by one. Similarly for option + tab.

I tried control + w, it went through all the opened VSCode window too unless you use up and down keys to select.

Could anyone help?

Upvotes: 5

Views: 5132

Answers (3)

Code on the Rocks
Code on the Rocks

Reputation: 17566

I have a few options for you.

(Preferred) Quick Switch Window

Create a custom shortcut for workbench.action.quickSwitchWindow. This will do exactly what you want when you have 2 VS Code projects open.

As a bonus, install the Peacock VS Code extension and set your windows to unique colors


Switch Window

Create a custom shortcut for workbench.action.switchWindow. Using this command will show you a list of all open windows and you can select the one you want to go to.

Open Recent

Create a custom shortcut for workbench.action.openRecent. Using this command will show you a list of the most recent files you had open.

Upvotes: 0

Dreamy Player
Dreamy Player

Reputation: 615

Solution 1

  • Command + Shift + [: switch to the previous window
  • Command + Shift + ]: switch to the next window

These shortcuts allow you to switch between the last two Visual Studio Code windows.

OR

open command pallete CMD+SHIFT+P and search for Window: Focus Next Group or Window: Focus Previous Group commands to switch between the last two Visual Studio Code windows.

Solution 2

  • 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
  • Use Ctrl + PageUp/PageDow to switch between panes.
  • ⌘K ⌘← / ⌘K ⌘→ Focus into previous/next editor group

Solution 3

You have to edit keybindings.json. Use the Command Palette with CMD+SHIFT+P, enter "Preferences: Open Keyboard Shortcuts (JSON)", and hit enter.

Then add to the end of the file:

[
    // ...
    {
        "key": "ctrl+tab",
        "command": "workbench.action.focusPreviousGroup"
    },
    {
        "key": "ctrl+tab", // or change custom shortcuts
        "command": "workbench.action.focusNextGroup"
    }
]

OR

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

OR

[
  {
    "key": "ctrl+tab",
    "command": "workbench.action.quickOpenPreviousRecentlyUsedEditor",
    "when": "!inEditorsPicker"
  }
]

Upvotes: 2

picchiolu
picchiolu

Reputation: 1130

I have the following mapped to alt+tab, in keybindings.json:

{
  "key": "alt+tab",
  "command": "workbench.action.quickOpenRecent",
  "when": "!inRecentFilesPicker"
},
{
  "key": "alt+tab",
  "command": "workbench.action.quickOpenNavigateNextInRecentFilesPicker",
  "when": "inQuickOpen && inRecentFilesPicker"
},
{
  "key": "shift+alt+tab",
  "command": "workbench.action.quickOpenNavigatePreviousInRecentFilesPicker",
  "when": "inQuickOpen && inRecentFilesPicker"
}

Upvotes: 1

Related Questions