Skip to content

vim: Fix word object count multiplier (2aw, 2iw)#45686

Merged
ConradIrwin merged 4 commits intozed-industries:mainfrom
MateoKruk:matt/fix-vim-word-object-count
Jan 5, 2026
Merged

vim: Fix word object count multiplier (2aw, 2iw)#45686
ConradIrwin merged 4 commits intozed-industries:mainfrom
MateoKruk:matt/fix-vim-word-object-count

Conversation

@MateoKruk
Copy link
Contributor

@MateoKruk MateoKruk commented Dec 26, 2025

Closes #44251

Context

Commands like 2daw or c2iw were ignoring the count multiplier because the word text object functions (in_word, around_word) weren't using the times parameter. This fix propagates the count through these functions so all operators correctly handle multiple words.

Before

Screen.Recording.2025-12-26.at.12.22.44.PM.mov

After

Screen.Recording.2025-12-26.at.12.23.43.PM.mov

Release Notes:

  • Fixed vim mode count multiplier for word text objects (2aw, 2iw, 2aW, 2iW)

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 26, 2025
@MateoKruk MateoKruk marked this pull request as ready for review December 26, 2025 15:25
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MateoKruk MateoKruk force-pushed the matt/fix-vim-word-object-count branch from 51fba6b to e021c61 Compare December 26, 2025 15:39
Previously, commands like `d2aw` or `2daw` would only delete a single
word, ignoring the numeric multiplier. This was because the `times`
parameter was passed through the system but the word text object
functions (`in_word`, `around_word`) ignored it.

This change adds `times` parameter support to:
- `in_word()`: Extends selection to include N words
- `around_word()`: Propagates times to helper functions
- `around_containing_word()`: Passes times to in_word()
- `around_next_word()`: Counts words and stops at Nth word
- `Object::range()`: Passes times.unwrap_or(1) to word functions
@MateoKruk MateoKruk force-pushed the matt/fix-vim-word-object-count branch from e021c61 to 6452283 Compare December 26, 2025 15:52
@MateoKruk MateoKruk marked this pull request as draft December 26, 2025 16:00
@MateoKruk MateoKruk force-pushed the matt/fix-vim-word-object-count branch from fcc18f6 to 554d76e Compare December 26, 2025 16:17
@MateoKruk MateoKruk marked this pull request as ready for review December 26, 2025 16:18
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MateoKruk MateoKruk changed the title vim: Fix word object count multiplier (d2aw, 2daw) vim: Fix word object count multiplier (2aw, 2iw) Dec 27, 2025
@Kalmaegi
Copy link
Contributor

We might need to handle cases where multiple operations include line breaks.

@MateoKruk
Copy link
Contributor Author

@Kalmaegi good catch

@ConradIrwin
Copy link
Member

Thank you, and thanks for the tests!

@ConradIrwin ConradIrwin merged commit 4dd54c6 into zed-industries:main Jan 5, 2026
23 checks passed
@MateoKruk MateoKruk deleted the matt/fix-vim-word-object-count branch January 5, 2026 17:05
@MateoKruk
Copy link
Contributor Author

thanks @ConradIrwin!

LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
Closes zed-industries#44251

## Context

Commands like `2daw` or `c2iw` were ignoring the count multiplier
because the word text object functions (`in_word`, `around_word`)
weren't using the `times` parameter. This fix propagates the count
through these functions so all operators correctly handle multiple
words.

## Before


https://github.com/user-attachments/assets/d5effa8a-4c04-4d70-a6b5-389cba730ca9

## After


https://github.com/user-attachments/assets/c50e4c0c-ea5c-4673-9c98-3d924b448025


Release Notes:

- Fixed vim mode count multiplier for word text objects (`2aw`, `2iw`,
`2aW`, `2iW`)
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
Closes zed-industries#44251

## Context

Commands like `2daw` or `c2iw` were ignoring the count multiplier
because the word text object functions (`in_word`, `around_word`)
weren't using the `times` parameter. This fix propagates the count
through these functions so all operators correctly handle multiple
words.

## Before


https://github.com/user-attachments/assets/d5effa8a-4c04-4d70-a6b5-389cba730ca9

## After


https://github.com/user-attachments/assets/c50e4c0c-ea5c-4673-9c98-3d924b448025


Release Notes:

- Fixed vim mode count multiplier for word text objects (`2aw`, `2iw`,
`2aW`, `2iW`)
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

None yet

Development

Successfully merging this pull request may close these issues.

vim mode: d2aw and 2daw only delete one word

4 participants