542

The current function of giving me a dropdown option of which tab to choose is just so annoying. Is there a possibility to remove it so the tabs would work like in some modern web browser.

4

22 回答 22

956

By default, Ctrl+Tab in Visual Studio Code cycles through tabs in order of most recently used. This is confusing because it depends on hidden state.

Web browsers cycle through tabs in visible order. This is much more intuitive.

To achieve this in Visual Studio Code, you have to edit keybindings.json. Use the Command Palette with CTRL+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.nextEditor"
    },
    {
        "key": "ctrl+shift+tab",
        "command": "workbench.action.previousEditor"
    }
]

Alternatively, to only cycle through tabs of the current window/split view, you can use:

[
    {
        "key": "ctrl+tab",
        "command": "workbench.action.nextEditorInGroup"
    },
    {
        "key": "ctrl+shift+tab",
        "command": "workbench.action.previousEditorInGroup"
    }
]

Alternatively, you can use Ctrl+PageDown (Windows) or Cmd+Option+Right (Mac).

于 2016-08-16T15:33:26.177 回答
267

@Combii I found a way to swap

CMD+1, CMD+2, CMD+3 with CTRL+1, CTRL+2, CTRL+3, ...

In macOS, go to:

Code > Preferences > Keyboard Shortcuts

On that page, click the button on the top right of the page...

edit keybindings.json button

and append the configuration below, then save.

[
    {
        "key": "cmd+0",
        "command": "workbench.action.openLastEditorInGroup"
    },
    {
        "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"
    },
    {
        "key": "ctrl+1",
        "command": "workbench.action.focusFirstEditorGroup"
    },
    {
        "key": "ctrl+2",
        "command": "workbench.action.focusSecondEditorGroup"
    },
    {
        "key": "ctrl+3",
        "command": "workbench.action.focusThirdEditorGroup"
    }
]

You now can use CMD+[1-9] to switch between tabs and CTRL+[1-3] to focus editor groups! Hope this answer is helpful.

于 2017-09-07T03:19:52.983 回答
114

Windows

When using Visual Studio Code on Windows, you can use CTRL + PAGE_UP to switch to the previous tab, and CTRL + PAGE_DN to switch to the next tab.

You also have the ability to switch to tabs based on their (non-zero relative) index. You can do so, by pressing and holding ALT, followed by a number (1 through 9).

macOS

To quickly navigate between tabs, press and hold the CMD key, followed by the number (1 through 9) of the tab you want to switch to.

You also have the ability to switch between the previous/next tab via the CMD + ALT + LEFT/RIGHT keyboard shortcut.

Please note that in order to switch to a tab that is in a different editor group, you must first switch to the desired editor group.

Pro Tip: If you aren't comfortable with any of the key bindings, you can change them to whatever you feel more comfortable with!

于 2016-08-15T20:28:37.380 回答
68

Mac OS

Prev tab: Shift + Cmd + [

Next Tab: Shift + Cmd + ]

Mac OS (alternative)

Prev tab: Cmnd + Alt + ←</kbd>

Next Tab: Cmnd + Alt + →</kbd>

Windows:

Prev tab: Ctrl + Shift + Tab

Next tab: Ctrl + Tab

Linux / Windows (alternative):

Prev tab: Ctrl + Page Down

Next tab: Ctrl + Page Up

于 2018-03-06T17:20:59.027 回答
68

If you are using the VSCodeVim extension, you can use the Vim key shortcuts:

Next tab: gt

Prior tab: gT

Numbered tab: nnngt

于 2018-07-18T16:55:17.763 回答
28

macOS - revised 2017

IN 2017, the VS CODE keyboard shortcuts have changed to CTRL+1, CTRL+2,CTRL+3 etc..to switch between tabs.

CMD+1, CMD+2, and CMD+3 switch between and create tab groups

于 2017-06-30T18:51:39.117 回答
22

Windows

previous

Ctrl + Shift + Tab

Next

Ctrl + Tab

Mac OS

previous

Shift+ Cmd + [

Next

Shift + Cmd + ]

于 2019-08-13T04:43:25.217 回答
12

Better approch is use alt+right and alt+left keys to navigate like Jetbrains IDE Webstorm does

Here is my config. it also include create new file and folder

    {
        "key": "ctrl+n",
        "command": "explorer.newFile"
    },
    {
        "key": "ctrl+shift+n",
        "command": "explorer.newFolder"
    },
    { 
        "key": "alt+left",
        "command": "workbench.action.previousEditor" 
    },
    { 
        "key": "alt+right",
        "command": "workbench.action.nextEditor" 
    }
于 2017-09-27T10:09:04.047 回答
7

Visual Studio Code v1.35.0 let's you set the (Ctrl+Tab) / (Shift+Ctrl+Tab) key sequences to sequentially switch between editors by binding those keys sequences to the commands "View: Open Next Editor" and "View: Open Previous Editor", respectively.

On macOS:

  1. Navigate to: Code > Preferences > Keyboard Shortcuts
  2. Search or navigate down to the following two options:
    • View: Open Next Editor
    • View: Open Previous Editor
  3. Change both keybindings to the desired key sequence.
    • View: Open Next Editor -> (Ctrl+Tab)
    • View: Open Previous Editor -> (Shift+Ctrl+Tab)
  4. You will likely run into a conflicting binding. If so, take note of the command and reassign or remove the existing key binding.

If you mess up, you can always revert back to the default state for a given binding by right-clicking on any keybinding and selecting "Reset Keybinding".

于 2019-06-10T19:08:20.960 回答
6

for linux... I use ctrl+pageUp or pageDown

于 2018-06-02T01:58:04.140 回答
5

Linux key-map to match the browser:

[
    {
        "key": "ctrl+0",
        "command": "workbench.action.lastEditorInGroup"
    },
    {
        "key": "ctrl+1",
        "command": "workbench.action.openEditorAtIndex1"
    },
    {
        "key": "ctrl+2",
        "command": "workbench.action.openEditorAtIndex2"
    },
    {
        "key": "ctrl+3",
        "command": "workbench.action.openEditorAtIndex3"
    },
    {
        "key": "ctrl+4",
        "command": "workbench.action.openEditorAtIndex4"
    },
    {
        "key": "ctrl+5",
        "command": "workbench.action.openEditorAtIndex5"
    },
    {
        "key": "ctrl+6",
        "command": "workbench.action.openEditorAtIndex6"
    },
    {
        "key": "ctrl+7",
        "command": "workbench.action.openEditorAtIndex7"
    },
    {
        "key": "ctrl+8",
        "command": "workbench.action.openEditorAtIndex8"
    },
    {
        "key": "ctrl+9",
        "command": "workbench.action.openEditorAtIndex9"
    },
    {
        "key": "alt+1",
        "command": "workbench.action.focusFirstEditorGroup"
    },
    {
        "key": "alt+2",
        "command": "workbench.action.focusSecondEditorGroup"
    },
    {
        "key": "alt+3",
        "command": "workbench.action.focusThirdEditorGroup"
    }
]
于 2020-01-21T17:25:59.143 回答
5

Another way to quickly change tabs would be in VSCode 1.45 (April 2020)

Switch tabs using mouse wheel

When you use the mouse wheel to scroll over editor tabs, you can currently not switch to the tab, only reveal tabs that are out of view.

Now with a new setting workbench.editor.scrollToSwitchTabs this behaviour can be changed if you change it to true.

https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_45/scroll-tabs.gif

Note: you can also press and hold the Shift key while scrolling to get the opposite behaviour (i.e. you can switch to tabs even with this setting being turned off).

于 2020-04-23T19:39:27.847 回答
4

When using Visual Studio Code on Linux/Windows, you can use CTRL + PAGE_UP to switch to the previous tab, and CTRL + PAGE_DN to switch to the next tab. You also have the ability to switch to tabs based on their (non-zero relative) index. You can do so, by pressing and holding ALT , followed by a number (1 through 9).

For more details: check here

于 2019-02-25T15:00:50.693 回答
3

This also works on MAC OS:

Press for select specific Tab: Control + 1 or Control 2, Control 3, etc.

Press for show/select all posible Tabs: Control + Tab.

于 2019-02-27T23:20:38.293 回答
3

I find it really annoying that CTRL+TAB and CTRL+SHIFT+TAB only cycle through the open files in a panel (instead of all panels) when I have windows split in multiple panels. To change the behaviour so that it cycles through all panels while retaining the behaviour once inside of the quick open dialog, add these to your keybindings:

  {
    "key": "ctrl+tab",
    "command": "workbench.action.quickOpenPreviousRecentlyUsedEditor"
  },
  {
    "key": "ctrl+shift+tab",
    "command": "workbench.action.quickOpenLeastRecentlyUsedEditor"
  },
  {
    "key": "ctrl+tab",
    "command": "workbench.action.quickOpenNavigateNextInEditorPicker",
    "when": "inEditorsPicker && inQuickOpen"
  },
  {
    "key": "ctrl+shift+tab",
    "command": "workbench.action.quickOpenNavigatePreviousInEditorPicker",
    "when": "inEditorsPicker && inQuickOpen"
  }
于 2021-03-26T05:11:54.570 回答
3

There are multiple ways through which you would can toggle the tabs.

  1. Modern browser way based on position.
{
       "key": "ctrl+tab",
       "command": "workbench.action.nextEditor"
   },
   {
       "key": "ctrl+shift+tab",
       "command": "workbench.action.previousEditor"
   }
  1. Recently sorted
{
   "key": "ctrl+shift+tab",
   "command": "workbench.action.openNextRecentlyUsedEditor"
 },
 {
   "key": "ctrl+tab",
   "command": "workbench.action.openPreviousRecentlyUsedEditor"
 }
于 2021-08-12T12:11:22.723 回答
2

Linux In current Vscode 1.44.1 version

we could use ctrl+pageup for next editor and ctrl+pagedown for previous editor.

If there is a need to change

ctrl+shift+p > Preferences:Open Keyboard Shortcuts.

search for

nextEditor

change if needed by clicking it.

于 2020-06-25T07:26:29.950 回答
1

@SC_Chupacabra has correct answer for modifying behavior.

I generally prefer CTRL + PAGE UP / DOWN for my navigation, rather than using the TAB key.

    {
        "key": "ctrl+pageUp",
        "command": "workbench.action.nextEditor"
    },
    {
        "key": "ctrl+pageDown",
        "command": "workbench.action.previousEditor"
    }
于 2020-01-02T04:23:24.010 回答
0

Use Sublime Text Keymaps. So much more intuitive.

⌘</kbd>k⌘</kbd>m

Import Sublime Text Keymaps:

Name: Sublime Text Keymap and Settings Importer
Id: ms-vscode.sublime-keybindings
Description: Import Sublime Text settings and keybindings into VS Code.
Version: 4.0.3
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.sublime-keybindings
于 2019-08-13T04:12:32.913 回答
0

I couldn't find a post for VS Community, so I'll post my solution here.


First, you need to go to Tools -> Options -> Environment -> Keyboard, then find the command Window.NextTab. Near the bottom it should say "Use new shortcut in: ". Set that to Global (should be default), then select the textbox to the right and hit Ctrl + Tab. Remove all current shortcuts for the selected command, and hit Assign. For Ctrl + Shift + Tab, the command should be Window.PreviousTab.

Hope this helps :) If there's a separate post for VS Community, I'd gladly move this post over.

于 2020-06-05T21:23:51.647 回答
0

I'm using this script for AutoHotKey

^+WheelUp::
   WinGetActiveTitle, originalWindow
   WinActivate, ahk_exe Code.exe
   Send ^{PgDn}
   WinActivate, %originalWindow%
return

This lets me hold control + shift and use my scroll wheel to move between VSCode tabs even with another program focused. I use something similar for browser tabs and video control.

于 2021-08-25T05:07:16.720 回答
0

Vim users might find these key bindings natural for switching between groups and windows within groups:

    { "key": "ctrl+j", "command": "workbench.action.nextEditorInGroup" },
    { "key": "ctrl+k", "command": "workbench.action.previousEditorInGroup" },
    { "key": "ctrl+h", "command": "workbench.action.focusPreviousGroup" },
    { "key": "ctrl+l", "command": "workbench.action.focusNextGroup" }
于 2022-03-02T18:25:16.043 回答