Skip to content

Comments

feat(cli): Add W, B, E Vim motions and operator support#16209

Merged
scidomino merged 9 commits intogoogle-gemini:mainfrom
ademuri:galzahavi/improve/vim-mode
Feb 5, 2026
Merged

feat(cli): Add W, B, E Vim motions and operator support#16209
scidomino merged 9 commits intogoogle-gemini:mainfrom
ademuri:galzahavi/improve/vim-mode

Conversation

@ademuri
Copy link
Contributor

@ademuri ademuri commented Jan 8, 2026

Summary

This change adds support for "Big Word" navigation in Vim mode:
- W: Move forward by big word (space-delimited).
- B: Move backward by big word.
- E: Move to end of big word.

It also supports these motions with operators (d, c):
- dW, cW, dB, cB, dE, cE.                                                                                                             
                                                                                                                                      
Implementation details:                                                                                                               
- Added helper functions findNextBigWordStartInLine, findPrevBigWordStartInLine, findBigWordEndInLine and their cross-line counterpar.
- Added corresponding actions to TextBuffer and vim-buffer-actions.ts.                                                                
- Updated vim.ts to map keys and handle operator motions.                                                                             
- Added comprehensive unit tests in text-buffer.test.ts and integration tests in vim.test.tsx.

This PR also contains fixes to the currently-broken Vim mode tests.

Closes #16768.

How to Validate

Run the Gemini CLI. Enable Vim mode in settings. Type some text, using punctuation in some of the words (e.g. "Here is some!text. Test.txt.bak i^s a word with periods."). Press Esc to enter command mode. Then, use W, E, and B to move the cursor between words. Compare the behavior with the lowercase versions.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ademuri, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Vim mode experience within the CLI by introducing 'Big Word' navigation (W, B, E) and integrating these motions with delete and change operators. This allows users to move and manipulate text more efficiently, treating sequences of non-whitespace characters as single units, which is particularly useful for code and structured text. The changes involve core text buffer logic, UI integration, and thorough testing to ensure robustness.

Highlights

  • Vim "Big Word" Navigation: Introduced 'W', 'B', and 'E' motions for navigating by 'big words' (space-delimited sequences of non-whitespace characters), enhancing text manipulation efficiency.
  • Operator Support: Integrated 'W', 'B', and 'E' motions with Vim operators 'd' (delete) and 'c' (change), allowing for commands like 'dW', 'cW', 'dB', 'cB', 'dE', and 'cE'.
  • Core Logic Implementation: Added new helper functions (e.g., 'findNextBigWordStartInLine', 'findPrevBigWordStartInLine', 'findBigWordEndInLine', and their cross-line counterparts) to 'text-buffer.ts' to accurately define 'big word' boundaries.
  • Text Buffer Actions & Vim Hook Integration: Extended the 'TextBuffer' with new action types and reducer logic for big word movements, deletions, and changes, and updated the 'useVim' hook to map key sequences to these new actions.
  • Comprehensive Testing: Included new unit tests for the big word navigation helpers and integration tests for the 'useVim' hook to ensure the correct functionality of all new motions and operators.
  • New Configuration Options: Added 'general.disableVimCommandMode' and 'general.vimModeStyle' settings, along with their documentation, to provide users with more control over Vim mode behavior.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for 'Big Word' navigation (W, B, E) in Vim mode, including operator support with 'd' and 'c'. The implementation includes new helper functions for word navigation, corresponding actions in the text buffer, and updates to the Vim hook to handle the new key mappings. The changes are well-tested with new unit and integration tests.

My main feedback is a critical performance issue in the findNextBigWordAcrossLines function, which could lead to UI unresponsiveness on large files with many empty lines due to a nested loop. I've provided a comment with details on the issue and a suggestion for refactoring.

@ademuri
Copy link
Contributor Author

ademuri commented Jan 9, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for "Big Word" navigation (W, B, E) and their corresponding operator motions in Vim mode. The implementation includes new helper functions for word navigation, updates to the text buffer actions, and integration into the useVim hook. The changes are well-supported by new unit and integration tests, and the documentation has been updated accordingly. My review identified two high-severity issues in the buffer action implementations: a correctness bug in the dW/cW behavior at the end of a line, and a maintainability concern due to redundant logic in the E motion handler. Addressing these will improve the accuracy of the Vim emulation and the long-term health of the codebase.

@ademuri
Copy link
Contributor Author

ademuri commented Jan 9, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces "Big Word" navigation (W, B, E) and operator support (d, c) to the Vim mode, a valuable enhancement for CLI usability. The implementation is comprehensive, including new helper functions, text buffer actions, and updates to the Vim hook, all supported by new unit and integration tests. I've identified a critical bug in the empty line handling for findNextBigWordAcrossLines and a high-severity issue in findBigWordEndInLine where the logic could be simplified for better maintainability. Addressing these points will solidify this excellent feature addition.

@ademuri
Copy link
Contributor Author

ademuri commented Jan 9, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for 'Big Word' navigation (W, B, E) in Vim mode, including operator support with 'd' and 'c'. The implementation includes new helper functions for word navigation, updates to the text buffer actions, and new key mappings in the Vim hook. The documentation and tests have also been updated accordingly. The changes are well-structured and the new feature is a great addition. I've found a couple of correctness issues with the delete/change word forward operations at the end of the buffer, where they behave like delete/change to end of line instead of operating on the word. My review includes suggestions to fix this behavior.

@ademuri
Copy link
Contributor Author

ademuri commented Jan 12, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for 'Big Word' navigation (W, B, E) in Vim mode, including operator support (d, c). The implementation adds new helper functions for word finding, extends text buffer actions, and updates the Vim key handling logic. The changes are well-structured and include documentation and test updates. However, I've found a critical copy-paste error that causes the backward 'Big Word' motions (B, dB, cB) to behave like their small-word counterparts, which I've detailed in the comments.

@ademuri
Copy link
Contributor Author

ademuri commented Jan 12, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces "Big Word" navigation (W, B, E) and operator support for Vim mode, which is a great enhancement. The implementation also includes several fixes and refactorings to the existing word navigation logic, improving its correctness and maintainability.

However, I've found a critical copy-paste error in the implementation of the backward "Big Word" operations (B, dB, cB). They are currently using the logic for regular words, which means they don't function as intended. Please see the detailed comments for the fix.

@ademuri
Copy link
Contributor Author

ademuri commented Jan 12, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for 'Big Word' navigation (W, B, E) in Vim mode, including operator support. The implementation is thorough, with new helper functions, updated actions, and comprehensive tests. I've identified a couple of high-severity behavioral bugs in the new dw/cw and dW/cW implementations where they don't correctly handle cases when the cursor is on whitespace, deviating from standard Vim behavior. I've provided suggestions to align them with user expectations. The rest of the changes, including documentation updates and other fixes, look good.

@ademuri ademuri marked this pull request as ready for review January 12, 2026 23:59
@ademuri ademuri requested a review from a team as a code owner January 12, 2026 23:59
@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Jan 13, 2026
@bdmorgan
Copy link
Collaborator

Hi @ademuri, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-cli gemini-cli bot added area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt area/core Issues related to User Interface, OS Support, Core Functionality and removed status/need-issue Pull requests that need to have an associated issue. labels Jan 19, 2026
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Jan 24, 2026

Hi there! Thank you for your contribution to Gemini CLI.

To improve our contribution process and better track changes, we now require all pull requests to be associated with an existing issue, as announced in our recent discussion and as detailed in our CONTRIBUTING.md.

This pull request is being closed because it is not currently linked to an issue. You can easily reopen this PR once you have linked it to an issue.

How to link an issue:
Add a keyword followed by the issue number (e.g., Fixes #123) in the description of your pull request. For more details, see the GitHub Documentation.

Thank you for your understanding and for being a part of our community!

@gemini-cli gemini-cli bot closed this Jan 24, 2026
@harshanadim
Copy link
Contributor

Hey @ademuri, this PR already has 'Closes #16768' in the body. You should be able to simply reopen it - the issue link should satisfy the new requirement.

@ademuri
Copy link
Contributor Author

ademuri commented Jan 26, 2026

I am unable to re-open this pull request. Can someone with permissions on the repo do that, or should I open a new pull request?

@harshanadim
Copy link
Contributor

@scidomino would you be able to help reopen this PR for @ademuri ?

@scidomino scidomino reopened this Jan 26, 2026
@scidomino scidomino requested a review from a team as a code owner January 26, 2026 17:46
@scidomino
Copy link
Collaborator

Please update and point your merge to main instead of google-gemini:galzahavi/improve/vim-mode

@ademuri ademuri marked this pull request as draft January 28, 2026 21:21
@ademuri ademuri force-pushed the galzahavi/improve/vim-mode branch 3 times, most recently from 8e68ef0 to 83ca49d Compare January 29, 2026 00:42
@ademuri ademuri marked this pull request as ready for review January 29, 2026 00:42
@scidomino
Copy link
Collaborator

I'm seeing some failing tests. Please fix.

@chrstnb
Copy link
Collaborator

chrstnb commented Feb 4, 2026

Build failed: Build process failed with link errors:

21:15:16 [ERROR] ✗ Found 1 invalid link in 1 file.
21:15:16   └─ /docs/cli/vim-mode - invalid link
21:15:16 [ERROR] [starlight-links-validator-integration] An unhandled error occurred while running the "astro:build:done" hook

This change adds support for "Big Word" navigation in Vim mode:
- W: Move forward by big word (space-delimited).
- B: Move backward by big word.
- E: Move to end of big word.

It also supports these motions with operators (d, c):
- dW, cW, dB, cB, dE, cE.

Implementation details:
- Added helper functions findNextBigWordStartInLine, findPrevBigWordStartInLine, findBigWordEndInLine and their cross-line counterparts to text-buffer.ts.
- Added corresponding actions to TextBuffer and vim-buffer-actions.ts.
- Updated vim.ts to map keys and handle operator motions.
- Added comprehensive unit tests in text-buffer.test.ts and integration tests in vim.test.tsx.
@ademuri ademuri force-pushed the galzahavi/improve/vim-mode branch from 21e877c to dc09ba1 Compare February 5, 2026 00:25
@ademuri
Copy link
Contributor Author

ademuri commented Feb 5, 2026

Rebased, fixed the failing tests, and removed the link to the non-existent document. Some of the tests failed locally for me, but also failed at main, so I believe they are unrelated.

@scidomino scidomino added this pull request to the merge queue Feb 5, 2026
Merged via the queue into google-gemini:main with commit ee2c8ee Feb 5, 2026
26 checks passed
@ademuri ademuri deleted the galzahavi/improve/vim-mode branch February 5, 2026 18:36
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
…i#16209)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
aswinashok44 pushed a commit to aswinashok44/gemini-cli that referenced this pull request Feb 9, 2026
…i#16209)

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

Labels

area/core Issues related to User Interface, OS Support, Core Functionality area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for "big word" movements in Vim mode

5 participants