# vim: Fix \`cw\` with count greater than 1 not preserving whitespace correctly \(\#56585\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/3fc012ef4b572dc153c31baf9a949b96a5a08672)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 3fc012ef4b572dc153c31baf9a949b96a5a08672

Requested commit: 3fc012ef4b572dc153c31baf9a949b96a5a08672

Commit: 3fc012ef4b572dc153c31baf9a949b96a5a08672

Tree: a89135c80163402463c90f40d3b309077e9e0aed

Author: davidhi7

Committer: GitHub

## Message

```
vim: Fix `cw` with count greater than 1 not preserving whitespace correctly  (#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 #56563.

Release Notes:

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

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
```

## Parents

- [adb8a1d80f96829b86b0140783651dc8b8dde9ee](https://git.cafe/gitcafe/zed/commit/adb8a1d80f96829b86b0140783651dc8b8dde9ee?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/3fc012ef4b572dc153c31baf9a949b96a5a08672?format=markdown)
