简体   繁体   中英

visual studio code go to a tab by number

In chrome and most other browsers/editors, we can go to a particular tab by pressing the Command key and the number. For example: If we press Command+1 we will go to the first tab, Command+2 takes to the second tab, etc.

Is it possible to get such a key mapping for Visual studio code ?

This is available now, with the latest version of Visual Studio Code. See: https://github.com/Microsoft/vscode/issues/24753#issuecomment-294518439

On macOS, the shortcuts default to ctrl + n , not cmd + n . You can fix that in Code -> Preferences -> Keyboard Shortcuts. Another note: most other apps activate the last tab with cmd + 9 . I'm not sure whether VSCode can do that easily.

Since VSCode uses ctrl+number by default (which changes desktops in macOS), you can use cmd+number with custom keybindings:

Paste this in your keybindings.user :

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

Unfortunately, no. But you can configure shortcuts to move between tabs, such as going to the previous, next, previously modified, etc. tabs. You can make changes in the Options menu under Keyboard.

This comes standard with the "Emacs Keymap" extension as well as a multitude of other "never touch the mouse" keybindings that I, personally, find keep my stress level way down while navigating code.

Now all I need to find is a way to put the tab's number on the tab itself (which is what I was searching when I found this question).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM