Skip to content

workspace: Add ctrl-w x support for vim#42792

Merged
ConradIrwin merged 2 commits intozed-industries:mainfrom
mfroeh:vim-ctrl-w-x
Dec 2, 2025
Merged

workspace: Add ctrl-w x support for vim#42792
ConradIrwin merged 2 commits intozed-industries:mainfrom
mfroeh:vim-ctrl-w-x

Conversation

@mfroeh
Copy link
Contributor

@mfroeh mfroeh commented Nov 15, 2025

Adds support for the vim CTRL-W x keybinding, which swaps the active pane with the next adjacent one, prioritizing column over row and next over previous. Upon swap, the pane which was swapped with is activated (this is the vim behavior).

See also https://github.com/vim/vim/blob/ca6a260ef1a4b4ae94bc71c17cbabf8f12bf0f8c/runtime/doc/windows.txt#L514C1-L521C24

Release Notes:

  • Added ctrl-w x keybinding in Vim mode, which swaps the active window with the next adjacent one (aligning with Vim behavior)

Vim behavior

vim-horizontal.mp4
vim-vertical.mp4

Zed behavior

zed-horizontal.mp4
zed-vertical.mp4

Note: There is a discrepancy where in Vim, if vertical and horizontal splits are mixed, swapping from a column with a single window does not work (see the vertical video), whilst in Zed it does. However, I don't see a good reason as to why this should not be supported and would argue that it makes more sense to keep the clear priority swap behavior, instead of adding a workaround to supports such cases.

@cla-bot
Copy link

cla-bot bot commented Nov 15, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @mfroeh on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@mfroeh mfroeh changed the title workspace: adds CTRL-W x support workspace: Adds CTRL-W x support Nov 15, 2025
@mfroeh
Copy link
Contributor Author

mfroeh commented Nov 15, 2025

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 15, 2025
@cla-bot
Copy link

cla-bot bot commented Nov 15, 2025

The cla-bot has been summoned, and re-checked this pull request!

/// Swaps the current pane with the one below.
SwapPaneDown,
// Swaps the current pane with the first available adjacent pane (searching in order: below, above, right, left) and activates that pane.
SwapPaneDefault,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really sure about this name, happy to change this to any suggestion

@maxdeviant maxdeviant changed the title workspace: Adds CTRL-W x support workspace: Add ctrl-w x support for vim Nov 15, 2025
@ConradIrwin
Copy link
Member

Nice! Thank you. Went with SwapPaneAdjacent to closer match how you described the feature.

@ConradIrwin ConradIrwin enabled auto-merge (squash) December 2, 2025 03:27
@ConradIrwin ConradIrwin merged commit 2df5993 into zed-industries:main Dec 2, 2025
23 checks passed
@franciskafyi franciskafyi moved this from Community PRs to Done in Quality Week – December 2025 Dec 11, 2025
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
Adds support for the vim CTRL-W x keybinding, which swaps the active
pane with the next adjacent one, prioritizing column over row and next
over previous. Upon swap, the pane which was swapped with is activated
(this is the vim behavior).

See also
https://github.com/vim/vim/blob/ca6a260ef1a4b4ae94bc71c17cbabf8f12bf0f8c/runtime/doc/windows.txt#L514C1-L521C24

Release Notes:

- Added ctrl-w x keybinding in Vim mode, which swaps the active window
with the next adjacent one (aligning with Vim behavior)

**Vim behavior**


https://github.com/user-attachments/assets/435a8b52-5d1c-4d4b-964e-4f0f3c9aca31


https://github.com/user-attachments/assets/7aa40014-1eac-4cce-858f-516cd06d13f6

**Zed behavior**


https://github.com/user-attachments/assets/2431e860-4e11-45c6-a3f2-08f1a9b610c1


https://github.com/user-attachments/assets/30432d9d-5db1-4650-af30-232b1340229c

Note: There is a discrepancy where in Vim, if vertical and horizontal
splits are mixed, swapping from a column with a single window does not
work (see the vertical video), whilst in Zed it does. However, I don't
see a good reason as to why this should not be supported and would argue
that it makes more sense to keep the clear priority swap behavior,
instead of adding a workaround to supports such cases.

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

Development

Successfully merging this pull request may close these issues.

2 participants