Skip to content

vim: Fix cw with count greater than 1 not preserving whitespace correctly #56585

Merged
dinocosta merged 4 commits into
zed-industries:mainfrom
davidhi7:fix/c2w
Jun 18, 2026
Merged

vim: Fix cw with count greater than 1 not preserving whitespace correctly #56585
dinocosta merged 4 commits into
zed-industries:mainfrom
davidhi7:fix/c2w

Conversation

@davidhi7

@davidhi7 davidhi7 commented May 12, 2026

Copy link
Copy Markdown
Contributor

In vim, c {count} w diverges from the default w motion behavior: For change operations, the w motion will be treated like the e motion if the cursor is on a word, preserving whitespace after the N-th word. In zed, this special case was only implemented for a count of 1, falling back to incorrectly using the w motion if the count is greater than 1.

This PR generalizes this implementation to handle this special case for any count.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #56563.

Release Notes:

  • Fixed: vim cw with count greater than 1 not preserving whitespace correctly

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label May 12, 2026
@maxdeviant maxdeviant changed the title vim: cw with count greater than 1 not preserving whitespace correctly vim: Fix cw with count greater than 1 not preserving whitespace correctly May 12, 2026
@ChristopherBiscardi ChristopherBiscardi added the area:parity/vim Feedback for Vim parity features label May 12, 2026
@dinocosta dinocosta self-assigned this Jun 17, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 18, 2026

@dinocosta dinocosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @davidhi7 ! ✌️

@dinocosta dinocosta enabled auto-merge June 18, 2026 14:42
@dinocosta dinocosta added this pull request to the merge queue Jun 18, 2026
Merged via the queue into zed-industries:main with commit 3fc012e Jun 18, 2026
35 checks passed
weihuoya pushed a commit to weihuoya/zed that referenced this pull request Jun 25, 2026
…rectly (zed-industries#56585)

In vim, `c {count} w` diverges from the default `w` motion behavior: For
change operations, the `w` motion will be treated like the `e` motion if
the cursor is on a word, preserving whitespace after the N-th word. In
zed, this special case was only implemented for a count of 1, falling
back to incorrectly using the `w` motion if the count is greater than 1.

This PR generalizes this implementation to handle this special case for
any count.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#56563.

Release Notes:

- Fixed: vim `cw` with count greater than 1 not preserving whitespace
correctly

---------

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

Labels

area:parity/vim Feedback for Vim parity features cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vim c 2 w deletes the trailing whitespace

3 participants