zed icon indicating copy to clipboard operation
zed copied to clipboard

vim mode: Ctrl-w l will allow me to enter AI pane, but cannot go back this way

Open graf0 opened this issue 5 months ago • 4 comments
trafficstars

Summary

vim mode: Ctrl-w l will allow me to enter AI pane, but cannot go back this way

Description

Steps to reproduce:

  1. set vim mode
  2. open file and AI pane
  3. move to AI pane with Ctrl-w l
  4. Ctrl-w j - does nothing...

Expected Behavior: Ctrl-w j should move me again to editor.

Actual Behavior: you cannot go back same way, ie.: Ctrl-w j - Ctrl-w seems to not working at all in AI pan

Zed Version and System Specs

Zed: v0.188.5 (Zed) OS: Linux X11 debian 12 Memory: 62.6 GiB Architecture: x86_64 GPU: Intel(R) HD Graphics 530 (SKL GT2) || Intel open-source Mesa driver || Mesa 22.3.6

graf0 avatar Jun 03 '25 14:06 graf0

and in general - ctrl-w as vim shortcut for buffer management is inconsistent - I expect it to be everywhere, but sometimes ctrl-w just closes winodow (ie.: type :, then zlog, and you can close this window just by pressing ctrl-w) , sometimes it waits for rest of vim command

graf0 avatar Jun 03 '25 14:06 graf0

AI panel editor starts in insert mode, while shortcuts like ctrl-w j are defined for the normal mode. You can override this by adding this to your keymap.json:

  {
    "context": "MessageEditor > Editor && vim_mode == insert",
    "bindings": {
      "ctrl-w ctrl-h": ["workspace::SendKeystrokes", "escape ctrl-w h"],
      "ctrl-w h": ["workspace::SendKeystrokes", "escape ctrl-w h"]
      // Define for similar shortcuts
    }
  }

osyvokon avatar Jun 03 '25 14:06 osyvokon

Defining actions directly is even cleaner:

  {
    "context": "MessageEditor > Editor && vim_mode == insert",
    "bindings": {
      "ctrl-w ctrl-h": "workspace::ActivatePaneLeft",
      "ctrl-w h": "workspace::ActivatePaneLeft"
      // and so on
    }
  }

osyvokon avatar Jun 03 '25 14:06 osyvokon

Thank you! Unfortunately context "MessageEditor > Editor && vim_mode == insert" has no effect, but after changing it to: "MessageEditor > Editor" shortcut seems to work. But this is not something user expects when using vim mode. It seems like fast solution (hack?) to problem. It is acceptable - but maybe there should be info about that in docs? Ie.: what to paste into keymap.json to let ctrl-w window command of vim mode to work?

graf0 avatar Jun 04 '25 08:06 graf0

Glad that it worked!

Due to a recent change (#31915), the message editor now opens in Vim's insert mode. In this mode, ctrl-w behaves differently -- it's used to delete the previous word. That's why ctrl-w h doesn't work there by default.

However, if you switch to normal mode, ctrl-w h works as expected, matching Vim's usual behavior.

Enabling ctrl-w h directly in insert mode is a personal preference that sacrifices ctrl-w. I'm not sure if this override is common enough to be mentioned in the docs. Hopefully, anyone interested can find this GitHub issue!

osyvokon avatar Jun 04 '25 17:06 osyvokon

I'm going to close this issue for now as it seems to be solved, and general ctrl-w h/j/k/l consistency is another topic.

osyvokon avatar Jun 04 '25 17:06 osyvokon