zed icon indicating copy to clipboard operation
zed copied to clipboard

Tab Switcher MVP

Open alygin opened this issue 1 year ago • 7 comments

Draft of the Tab Switcher (#7653), just to gather feedback, if any.

Release Notes:

  • Added Tab Switcher

Current state:

https://github.com/zed-industries/zed/assets/2101250/863ca50a-d041-4c11-855e-c51bb6953abe

alygin avatar Feb 18 '24 20:02 alygin

I really like the feature! But I'm missing a default keybind configuration for it.

RemcoSmitsDev avatar Feb 18 '24 20:02 RemcoSmitsDev

I really like the feature! But I'm missing a default keybind configuration for it.

What keybinding do you think should be the default one for the tab switchier?

I also prefer having a shortcut to this feature, but none of the editors/IDEs I use provide it. VSCode doesn't even allow to set a custom one. I guess, the vast majority of the users prefer just clicking tabs, or navigate through them in some other manner. So I'm hesitant to propose a default keybinding, given that the user can always set the one he or she prefers.

alygin avatar Feb 19 '24 05:02 alygin

Ctrl+Tab in VS Code gives you something similar so that may be a reasonable keyboard shortcut. That is also common behavior in web browsers to page through your tabs with Ctrl+Tab. An alternative that comes to mind is Cmd+B because I think of tabs as buffers as a vim user.

fostertheweb avatar Feb 19 '24 05:02 fostertheweb

@fostertheweb, you're right, ctrl+tab in VSCode is a good example of how the tab switcher could look and behave. In the JetBrains products it works the same way, but provides more functionality. Unfortunately, the current state of the shortcuts handling in Zed doesn't allow to implement such behaviour easily (the same problem with the cmd+p in the file finder), but I'll give it another look.

cmd+b is already taken for the left dock show/hide, though cmd-k cmd-b is still vacant :)

alygin avatar Feb 19 '24 05:02 alygin

Regarding the key bindings, it’s just my personal opinion:

  • shift-shift: JetBrains
  • shift-`: More affectionate

d1y avatar Feb 19 '24 15:02 d1y

cmd+b is already taken for the left dock show/hide, though cmd-k cmd-b is still vacant :)

Whoops! I dock everything to the right so I had no idea.

I wonder how much more work it would be to allow for Ctrl+Tab.

fostertheweb avatar Feb 19 '24 17:02 fostertheweb

I wonder how much more work it would be to allow for Ctrl+Tab.

Here's a discussion of this feature: Action Release trigger

alygin avatar Feb 23 '24 22:02 alygin

@mikayla-maki, thanks for your help with mouse clicks!

alygin avatar Mar 27 '24 18:03 alygin

Well I discovered that CTRL-` will cycle between the shell and the upper pane so that's what I was looking for.

thynus avatar May 03 '24 23:05 thynus

I found it confusing that the keymap for the tab switcher was only in the Workspace context. I added the bindings to the Editor context too as that's where I usually am moving betwween files. Did I miss something obvious?

samjeffress avatar Jun 13 '24 10:06 samjeffress

@samjeffress, workspace contains editors, so whatever binding you add to the workspace context should work in the editor context too. Doesn't ctrl+tab work for you in an editor with the default configuration?

alygin avatar Jun 29 '24 09:06 alygin

@alygin with no custom bindings for "ctrl-tab", pressing "ctrl-tab" toggles between tabs without showing the list of open tabs (when in the editor). When I add the following to keymap.json the tab switcher appears:

  {
    "context": "Editor",
    "bindings": {
      "ctrl-tab": "tab_switcher::Toggle",
      "ctrl-shift-tab": [
        "tab_switcher::Toggle",
        {
          "select_last": true
        }
      ]
    }
  },

samjeffress avatar Jul 03 '24 06:07 samjeffress

Hi @samjeffress , Any idea on how to do this better with vim mode on? Just like we do in telescope?

anuragg-p avatar Jul 13 '24 10:07 anuragg-p