Support standard tab navigation key shortcuts on macOS #12831

Closed
matthewrk opened this Issue Sep 27, 2016 · 22 comments

Projects

None yet

8 participants

@matthewrk

macOS has OS wide shortcuts for navigating to the previous/next tab of:

cmd+shift+[
cmd+shift+]

Surprised to see that these don't work in VSCode. This was mentioned in #9333 but implemented as API commands and #8234 comes close but neither get all the way to making it standard for macOS or even making it an option for keybindings.json (as far as I can tell). Would be great for this to be supported.

@bpasero bpasero was assigned by joaomoreno Sep 28, 2016
@bpasero bpasero removed their assignment Sep 28, 2016
@bpasero
Member
bpasero commented Sep 28, 2016

Sounds like a good area for a Pull Request 👍

@bpasero
Member
bpasero commented Sep 28, 2016

Looks like we cannot do this because this keybinding is already taken by editor folding.

@bpasero bpasero removed the help wanted label Sep 28, 2016
@matthewrk

These are the standard os wide shortcuts for switching to the left/right tab, so on macOS any users who tried this would find it a little jarring if VSCode did nothing or worse something different altogether such as editor folding. Would that be a sufficient argument for remapping? Difficult territory I know.

@bpasero
Member
bpasero commented Sep 30, 2016

@alexandrudima and @aeschli should chime in why those keybindings got picked, they might as well be THE standard keybindings for folding, so it is a tough call.

@matthewrk
matthewrk commented Sep 30, 2016 edited

In comparison to other code editors, I can confirm that Atom, Sublime Text 2 and IntelliJ IDEA (with mac style bindings enabled) all use this shortcut for moving left/right a tab.

That's in addition to any standard Mac app that has tabs; Safari, Terminal, Finder, Messages etc.

@alexandrudima
Member

@aeschli knows

@kidoman
kidoman commented Oct 11, 2016

I would like to chime in here as well.

I have come from a big line of cult Mac OS X editors; TextMate, Sublime Text, and now VSCode.

The most jarring thing for me has been not being able to use Cmd+1,2,3 to switch tabs (guess what it probably works this way in your current browser if you are using Mac OS X to browse to this page, it does in Chrome for Mac OS X) and lot of other standards defined by the other editors not being followed in VSCode (or working imperfectly).

Although VSCode has now become my daily driver, it not respecting the lay of the land is continuing to be off putting #WhenInRome

@bpasero
Member
bpasero commented Oct 16, 2016

@kidoman agree, but it is also hard to change something that has worked in one way for a long time. we did not have tabs from day 1 and so Cmd+1 means something else in VS Code and many users might have gotten used to that.

You can always change keybindings easily, however I think what we need to do is provide a way for users to just say "I want Sublime keybindings" and you get it.

@waderyan fyi for this topic

@matthewrk
matthewrk commented Oct 16, 2016 edited

@bpasero Is there a way to manually rebind this currently using the json config file? I thought it wasn't exposed as an option.

+1 on the idea of enabling default sets of keybindings, IntelliJ IDEA does something similar (see attached screenshot). However its worth re-emphasising that this isn't "Sublime style" its a native macOS style, every app that I've tried with tabs supports this, code editors or otherwise. So perhaps better to name this preset "macOS Native" rather than "Sublime", if it were to have a name.

screen shot 2016-10-16 at 18 06 24

@bpasero
Member
bpasero commented Oct 17, 2016

@matthewrk you can try to assign to these actions:

  • workbench.action.openNextRecentlyUsedEditorInGroup
  • workbench.action.openPreviousRecentlyUsedEditorInGroup
  • workbench.action.nextEditor
  • workbench.action.previousEditor

The latter commands allow to navigate across groups.

@matthewrk

@bpasero thanks! the nextEditor / previousEditor was what I was after.

@kidoman
kidoman commented Oct 22, 2016

Currency using this and it works quite well:

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

Posting this till a more permanent "Behave like Sublime / Mac OS X native option is added"

@bpasero
Member
bpasero commented Oct 23, 2016

@waderyan you might want to maybe add this to the ST keybinding extension?

@waderyan
Member

@bpasero added. Thank you!

@kidoman can I get your feedback on this extension I have built to try and close these gaps?

We can take this offline from this issue. Please ping me directly wade.anderson@microsoft.com

@matthewrk
matthewrk commented Nov 2, 2016 edited

@bpasero I'm happy to consider this issue closed as I am able to do what I need via custom keybindings as you provided or via the sublime keybinding extension.

However, in a more general sense by default Visual Studio Code is still not honouring default mac key shortcuts and the solution isn't immediately clear on how they can resolve this. These key shortcuts are part of the sublime extension but sublime only has them because they're mac defaults, so they're not sublime key shortcuts as such and mac users won't necessarily look to that extension naturally as a solution.

Not sure if that's something you or the team want to tackle, otherwise as mentioned, I'm happy for this issue to be closed on the basis that my exact issue is resolved with custom settings.

@bpasero
Member
bpasero commented Nov 3, 2016

We are looking into more solutions here, one possible idea is to ask the user on startup which keyscheme to use. Still, we should take a step back and look at all keybindings across OS to make them consistent 👍

@jupdike
jupdike commented Dec 21, 2016

I agree with @matthewrk. I am new to / really excited by VS Code and running into any issue like this where you feel like your fingers are chopped off is very jarring (hit expected combo and code disappears instead of changing tabs...).

If it could be possible to allow all existing users to keep the ("incorrect") folding Cmd+Shift+[ ] but all new users get Cmd+Shift+[ ] = changing tabs, that would be a very desireable improvement. (I mean, if you don't want to match Mac conventions, change Cmd+S for Save to Ctrl+S for Save and watch people fly off the handle. And if that suggestion is just plain stupid, then so is ignoring Mac tab-changing keyboard shortcut conventions.)

Not to be mean or pile on, but whoever picked those default shortcuts for code folding was demonstrably wrong and did not "speak the Mac keyboard shortcut language" natively or else they absolutely would not have picked the wrong shortcuts. The list of apps mentioned above should be enough proof that these shortcuts are supposed to be set aside for changing between tabs on macOS. (And the VS200X/Windows convention of the mini Ctrl+Tab/Cmd+Tab (but for open editor switching) is fine for what it does but that does not mean that Cmd+Shift+[ ] should not work as expected out of the box.) So this is a longwinded vote for "least surprise" and "feel as native as possible" and let people have a graceful onramp to VS Code by listening to long-time Mac users when they give you evidence that you made a mistake. (But only if you can do so without messing with people who have learned the "wrong" shortcuts because that would probably be even more confusing.)

And finally, I'm only commenting because I think something can be improved and because VS Code is super cool and deserves to be its best self and be as easy to transition to as possible.

@bpasero bpasero added this to the January 2017 milestone Dec 22, 2016
@bpasero bpasero self-assigned this Dec 22, 2016
@bpasero bpasero closed this in a67b1b1 Dec 22, 2016
@bpasero
Member
bpasero commented Dec 22, 2016 edited

I pushed a change to improve keybindings on macOS:

  • cmd+shift+] = Next Tab (works across multiple groups)
  • cmd+shift+[ = Previous Tab (works across multiple groups)
  • cmd+alt+[ = Fold All
  • cmd+alt+] = Unfold All
@matthewrk

@bpasero thanks for your work! I really hope that's cmd+shift+] for next tab though, rather than [ as you quoted...

@leegee
leegee commented Jan 12, 2017

Solution proposed, and issue closed, but not locked so — please add by default CMD+n for editor at index n. All other tabbed software has it, how on earth are you living without it?

@bpasero
Member
bpasero commented Jan 23, 2017 edited

how on earth are you living without it?

I was not and never will be using tabs, so for me it is natural that Cmd+1, Cmd+2 and Cmd+3 switch between editor groups.

@bpasero
Member
bpasero commented Jan 23, 2017
  • To verify:
  • cmd+shift+] = Next Tab (works across multiple groups)
  • cmd+shift+[ = Previous Tab (works across multiple groups)
  • cmd+alt+[ = Fold All
  • cmd+alt+] = Unfold All
@jrieken jrieken added the verified label Jan 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment