Lev
Lev

Reputation: 15654

How can I go back to previous tab opened in VScode

Is there a shortcut to go back to previous tab opened (not previous position of cursor as ^- does). Could not find such action in docs.

Upvotes: 5

Views: 5440

Answers (3)

Sargsian
Sargsian

Reputation: 17

You can use Ctrl + Page Up for previous tab and Ctrl + Page Down for next tab.

Upvotes: 2

Mark
Mark

Reputation: 180641

v1.42 introduces a bunch of new functionality - including the ability to cycle through recently used editors even when those editors are in different groups. See https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_42.md#navigate-most-recently-used-editors

Navigate most recently used editors

With this release, there is now a list of most recently used editors across all editor groups. An editor is considered recently used when it either opens as the active editor or becomes the new active editor if already opened. Once an editor is closed, it is removed from this list.

One application of this list is the new edt mru picker that you can open through the new View: Show All Editors By Most Recently Used (workbench.action.showAllEditorsByMostRecentlyUsed) command:

most recently used editors

You can add keyboard shortcuts to quickly navigate in this picker without using the mouse. For example, below is a keybinding to so that kbstyle(Ctrl+Tab) and kbstyle(Ctrl+Shift+Tab) navigates across editors of all groups (instead of only within the active group as the default keybindings do):

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

If you want to navigate the list without using a picker, there are new commands:

View: Open Next Recently Used Editor (`workbench.action.openNextRecentlyUsedEditor`)

View: Open Previous Recently Used Editor (`workbench.action.openPreviousRecentlyUsedEditor`)

To differentiate which editor navigation commands work with a picker and which ones don't, the behavior of some existing commands has changed. Specifically, the Recently Used Editor in Group commands no longer use a picker:

View: Open Next Recently Used Editor in Group (`workbench.action.openNextRecentlyUsedEditorInGroup`)

View: Open Previous Recently Used Editor in Group (`workbench.action.openPreviousRecentlyUsedEditorInGroup`)

Use View: Quick Open Previous Recently Used Editor in Group (workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup) and

View: Quick Open Least Recently Used Editor in Group (workbench.action.quickOpenLeastRecentlyUsedEditorInGroup) for picker-based navigation.


So I made these keybindings to go backward and forward through most recently used editors (regardless of which editor group they may be in):

  {
    "key": "alt+m",
    "command": "workbench.action.openNextRecentlyUsedEditor",
  },

 {
    "key": "shift+alt+m",
    "command": "workbench.action.openPreviousRecentlyUsedEditor",
  },

Upvotes: 2

Matt Bierner
Matt Bierner

Reputation: 65175

Try the View: Open Previous Editor command.

You can also view the editor history using the Open Previous Editor From History command, and then pick the target editor you wish to open

Upvotes: 4

Related Questions