Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move a single editor from one pane to another with vim ctrl-w #20205

Closed
1 task done
tbenthompson opened this issue Nov 4, 2024 · 7 comments · Fixed by #21760
Closed
1 task done

Move a single editor from one pane to another with vim ctrl-w #20205

tbenthompson opened this issue Nov 4, 2024 · 7 comments · Fixed by #21760
Labels
feature [core label] vim

Comments

@tbenthompson
Copy link

tbenthompson commented Nov 4, 2024

Check for existing issues

  • Completed

Describe the feature

In #5574 ctrl-w hjkl were set up to move between panes and ctrl-w HJKL to move a whole pane in a direction. I'm hoping for a variant of these commands that lets me move a single editor from one pane to another pane.

Unless I missed it, I don't think there's a command for this at the moment. I think having that command without any default keymapping would be wonderful.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

@Igonato
Copy link
Contributor

Igonato commented Nov 19, 2024

Not just vim. To support Sublime Text keybindings ctrl-shift-*number* would require a similar command, but for an nth pane.

I don't see any PRs open for anything similar, I'd like to take a swing at it.

So analogous to ActivatePane and ActivatePaneInDirection, would MoveToPane and MoveToPaneInDirection work? Or a bit more verbose MoveItemToPane and MoveItemToPaneInDirection?

@ConradIrwin
Copy link
Member

@Igonato please do! If. you want help feel free to book time here: https://calendly.com/conradirwin/pairing

Igonato added a commit to Igonato/zed that referenced this issue Dec 9, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
Igonato added a commit to Igonato/zed that referenced this issue Dec 9, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
@Igonato
Copy link
Contributor

Igonato commented Dec 9, 2024

Ready for feedback #21760

Question: should we close the pane if the last item has been moved from it?

  • Sublime doesn't, but Sublime's empty pane is just an editor w/o the tab.
  • When the last item is moved with a mouse, Zed closes the pane, Sublime doesn't.
  • So closing the pane w/o items is more consistent with the rest of the Zed's behavior

Example bindings:

            "alt-shift-h": ["workspace::MoveItemToPaneInDirection", "Left"],
            "alt-shift-l": ["workspace::MoveItemToPaneInDirection", "Right"],
            "alt-shift-k": ["workspace::MoveItemToPaneInDirection", "Up"],
            "alt-shift-j": ["workspace::MoveItemToPaneInDirection", "Down"],

            "ctrl-shift-1": ["workspace::MoveItemToPane", 0],
            "ctrl-shift-2": ["workspace::MoveItemToPane", 1],
            "ctrl-shift-3": ["workspace::MoveItemToPane", 2],
            "ctrl-shift-4": ["workspace::MoveItemToPane", 3],
            "ctrl-shift-5": ["workspace::MoveItemToPane", 4],
            "ctrl-shift-6": ["workspace::MoveItemToPane", 5],
            "ctrl-shift-7": ["workspace::MoveItemToPane", 6],
            "ctrl-shift-8": ["workspace::MoveItemToPane", 7],
            "ctrl-shift-9": ["workspace::MoveItemToPane", 8]

The latter should be added to the "base_keymap": "SublimeText" defaults. May I do it in the same PR? How do those work? Just edit default-*platform*.json after the comment, right?

Should I also add vim defaults? If so, which exact?

Igonato added a commit to Igonato/zed that referenced this issue Dec 10, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
Igonato added a commit to Igonato/zed that referenced this issue Dec 10, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
Igonato added a commit to Igonato/zed that referenced this issue Dec 10, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
Igonato added a commit to Igonato/zed that referenced this issue Dec 11, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
Igonato added a commit to Igonato/zed that referenced this issue Dec 14, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
Igonato added a commit to Igonato/zed that referenced this issue Dec 14, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
SomeoneToIgnore pushed a commit to Igonato/zed that referenced this issue Dec 17, 2024
Closes zed-industries#20205

An action to move the active editor to a pane in a specified direction
helgemahrt pushed a commit to helgemahrt/zed that referenced this issue Dec 18, 2024
Closes zed-industries#20205

Release Notes:

- Added `MoveItemToPane` and `MoveItemToPaneInDirection` actions

---------

Co-authored-by: Kirill Bulatov <[email protected]>
@domschab23
Copy link

Is this supposed to work when not using default sublime keybindings? I'm running zed version 0.166.1 on macos and I added following bindings to my keymap.json

  {
    "bindings": {
      "ctrl-1": ["workspace::ActivatePane", 0],
      "ctrl-2": ["workspace::ActivatePane", 1],
      "ctrl-3": ["workspace::ActivatePane", 2],
      "ctrl-4": ["workspace::ActivatePane", 3],
      "ctrl-5": ["workspace::ActivatePane", 4],
      "ctrl-6": ["workspace::ActivatePane", 5],
      "ctrl-7": ["workspace::ActivatePane", 6],
      "ctrl-8": ["workspace::ActivatePane", 7],
      "ctrl-9": ["workspace::ActivatePane", 8],
      "ctrl-shift-1": ["workspace::MoveItemToPane", { "destination": 0, "focus": true }],
      "ctrl-shift-2": ["workspace::MoveItemToPane", { "destination": 1 }],
      "ctrl-shift-3": ["workspace::MoveItemToPane", { "destination": 2 }],
      "ctrl-shift-4": ["workspace::MoveItemToPane", { "destination": 3 }],
      "ctrl-shift-5": ["workspace::MoveItemToPane", { "destination": 4 }],
      "ctrl-shift-6": ["workspace::MoveItemToPane", { "destination": 5 }],
      "ctrl-shift-7": ["workspace::MoveItemToPane", { "destination": 6 }],
      "ctrl-shift-8": ["workspace::MoveItemToPane", { "destination": 7 }],
      "ctrl-shift-9": ["workspace::MoveItemToPane", { "destination": 8 }]
    }
  },
  {

And nothing happens when I press ctrl-shift-{x}. ctrl-{x} works

I'm also not seeing commands mentioned in the PR in the default zed key bindings, but I'm guessing that's expected hence added them to my keymap.json

@Igonato
Copy link
Contributor

Igonato commented Dec 20, 2024

Is this supposed to work when not using default sublime keybindings

Yes. Those things are independent.

I'm also not seeing commands mentioned in the PR in the default zed key bindings, but I'm guessing that's expected hence added them to my keymap.json

Yes. They aren't part of any default other than Sublime based at the time.

And nothing happens when I press ctrl-shift-{x}. ctrl-{x} works

Do you have the panes created in advance (e. g. pane: split vertical)? It's not going to create them for you (maybe it would be nice if it did, but I decided to copy Sublime Text behaviour) .

Check that ctrl-shift-{x} isn't used by anything else, like keyboard layout switching. Try temporary changing the bindings to someting like arrow keys and see if it works then:

      "left": ["workspace::MoveItemToPane", { "destination": 0 }],
      "right": ["workspace::MoveItemToPane", { "destination": 1 }],

@domschab23
Copy link

domschab23 commented Dec 22, 2024

Thanks for replying over here!

yes, I do have at least 2 panes before doing that.

What I did is this

Added these keybindings to verify that they work at all

  {
    "bindings": {
      "alt-1": ["workspace::ActivatePane", 0],
      "alt-2": ["workspace::ActivatePane", 1],
      "alt-3": ["workspace::ActivatePane", 2],
      "alt-4": ["workspace::ActivatePane", 3]
    }
  },

And they worked (they don't do anything without assignment as expected).

Then i tried them with MoveItemToPane

  {
    "bindings": {
      // "alt-1": ["workspace::ActivatePane", 0],
      // "alt-2": ["workspace::ActivatePane", 1],
      // "alt-3": ["workspace::ActivatePane", 2],
      // "alt-4": ["workspace::ActivatePane", 3]
      "alt-1": ["workspace::MoveItemToPane", { "destination": 0 }],
      "alt-2": ["workspace::MoveItemToPane", { "destination": 1 }],
      "alt-3": ["workspace::MoveItemToPane", { "destination": 2 }],
      "alt-4": ["workspace::MoveItemToPane", { "destination": 3 }]
    }
  },

And nothing happens. Here's a recording

Screen.Recording.2024-12-22.at.1.18.05.PM.mov

I'm sure I'm doing something wrong, but I can't figure out what. They also don't work when I restart zed.

@Igonato
Copy link
Contributor

Igonato commented Dec 22, 2024

I guess one last thing to verify - is that you're not somehow using an older version of Zed without the change. Then it's a bug. Please, post the logs and the system info. I think it's better to create a separate issue, so we don't spam people in this closed one, feel free to @Igonato over there so I can look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature [core label] vim
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants