问题
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.
回答1:
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
回答2:
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:
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
) andView: 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",
},
来源:https://stackoverflow.com/questions/56077745/how-can-i-go-back-to-previous-tab-opened-in-vscode