How can I go back to previous tab opened in VScode

余生颓废 提交于 2021-02-16 22:59:22

问题


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) 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",
  },


来源:https://stackoverflow.com/questions/56077745/how-can-i-go-back-to-previous-tab-opened-in-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!