Skip to content

fix(vim): vim support that feels (more) complete#18755

Merged
scidomino merged 12 commits intogoogle-gemini:mainfrom
ppgranger:fix/vim-support
Feb 13, 2026
Merged

fix(vim): vim support that feels (more) complete#18755
scidomino merged 12 commits intogoogle-gemini:mainfrom
ppgranger:fix/vim-support

Conversation

@ppgranger
Copy link
Contributor

@ppgranger ppgranger commented Feb 10, 2026

Summary

Improve Vim mode by adding missing keybindings, fixing count prefix handling, and implementing delete operator with motions.

Details

Keybinding additions

  • Add Ctrl+[ as ESC alternative (standard Vim behavior for users who remap Caps Lock to Ctrl)
  • Enable Ctrl+U (kill line left) and Ctrl+K (kill line right) in Vim insert mode

Count prefix fixes

  • gg with count: 5gg now correctly goes to line 5 instead of always going to line 1
  • $ with count: 2$ now moves to end of next line (down 1 line, then to end)
  • . (repeat) with count: 3. now repeats the last command 3 times instead of ignoring the new count
  • D with count: 2D now deletes to end of current line and next line
  • C with count: 2C now changes to end of current line and next line

Missing commands

  • Add u (undo) handler in normal mode with count support (3u undoes 3 changes)
  • Add d$ to delete from cursor to end of line
  • Add d0 to delete from start of line to cursor
  • Add dh/dj/dk/dl to delete with directional motions
  • Support arrow keys with delete operator (d + arrow)

Cursor position fixes

  • ^ command now correctly clamps cursor position on empty or whitespace-only lines

Behavior fixes

  • Fix cj/ck/dj/dk to correctly delete current line + count lines (VIM behavior: 2dj deletes current line + 2 lines below = 3 lines total)

Related Issues

Fixes #14689
Fixes #15988
Fixes #17380
Related to #16846

Pre-Merge Checklist

  • Added/updated tests (if needed)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

- Add Ctrl+[ as an alternative key binding for ESCAPE command, matching
  standard Vim behavior where Ctrl+[ acts as ESC
- Allow Ctrl+U (kill line left) and Ctrl+K (kill line right) to pass
  through to InputPrompt in Vim insert mode, enabling standard line
  editing shortcuts

Fixes google-gemini#14689, google-gemini#17380
@ppgranger ppgranger requested a review from a team as a code owner February 10, 2026 20:33
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ppgranger, 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 enhances the Vim mode usability by introducing two key features. It adds support for Ctrl+[ as an alternative to the Escape key, a common Vim practice, and allows Ctrl+U and Ctrl+K for line editing in insert mode to pass through to the input prompt. These changes aim to provide a more complete and familiar Vim experience for users.

Highlights

  • Ctrl+[ as ESC: Implemented Ctrl+[ as an alternative to the Escape key, aligning with standard Vim behavior and user preferences for easier access.
  • Ctrl+U and Ctrl+K in Insert Mode: Enabled Ctrl+U (delete to start of line) and Ctrl+K (delete to end of line) to function correctly within Vim insert mode, matching Bash/Vim line editing behavior.
Changelog
  • packages/cli/src/config/keyBindings.ts
    • Added Ctrl+[ as an alternative keybinding for the ESCAPE command.
  • packages/cli/src/ui/hooks/vim.ts
    • Modified the Vim hook to allow Ctrl+U and Ctrl+K key combinations to be handled by the InputPrompt when in insert mode.
Activity
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.

- gg with count: 5gg now correctly goes to line 5 instead of line 1
- $ with count: 2$ now moves down 1 line then to end of line
- . (repeat) with count: 3. now repeats last command 3 times instead
  of using the original count
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 two quality-of-life improvements for vim mode. It adds Ctrl+[ as a standard alternative for the Escape key and enables Ctrl+U and Ctrl+K for line editing within insert mode. The changes are well-implemented and align with standard vim and shell behaviors. I have reviewed the code and found no issues.

@ppgranger ppgranger marked this pull request as draft February 10, 2026 20:40
@gemini-cli gemini-cli bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality labels Feb 10, 2026
@ppgranger
Copy link
Contributor Author

/review

- Add 'u' handler in normal mode to undo changes (supports count prefix)
- D command now respects count prefix (2D deletes to end of 2 lines)
- C command now respects count prefix (2C changes to end of 2 lines)
The ^ command now correctly positions the cursor at the last valid
character instead of past the end of line when the line is empty or
contains only whitespace.
@ppgranger ppgranger changed the title fix(vim): vim support that feels complete (nearly) fix(vim): vim support that feels (more) complete Feb 10, 2026
ppgranger and others added 2 commits February 11, 2026 21:22
- Add dh/dj/dk/dl commands to delete with directional motions
- Add d$ command to delete from cursor to end of line
- Add d0 command to delete from start of line to cursor
- Support arrow keys with delete operator (d+arrow)
- Add delete movement commands to executeCommand for repeat (.) support
- Create vimDeleteToStartOfLine method in text buffer
- Fix cj/ck/dj/dk to correctly delete current line + count lines
  (VIM behavior: 2dj deletes current line + 2 lines below = 3 lines)

Fixes google-gemini#15988
@ppgranger
Copy link
Contributor Author

/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 significantly improves the Vim mode by adding many missing keybindings and commands, and fixing several count-related bugs. The changes for gg, $, ., and directional movements like dj/dk are great additions and align well with standard Vim behavior.

I've identified a critical issue where the count prefix for the D, C, and d$ commands is not correctly implemented. While the PR description mentions this is fixed, the underlying logic doesn't handle multi-line operations for these commands. I've left a detailed comment with suggestions on how to address this.

Add missing VIM operator-motion commands:
- d^/c^: delete/change to first non-whitespace character
- c0: change to start of line
- dgg/cgg: delete/change from first line (or line N) to current line
- dG/cG: delete/change from current line to last line (or line N)

Fix D/C/d$/c$ to properly handle count prefix (e.g., 2D deletes to
EOL plus next line). Add comprehensive tests for all new commands
including edge cases for whitespace-only lines and bidirectional
deletion.
@ppgranger
Copy link
Contributor Author

/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 significantly enhances the Vim mode by adding many missing keybindings and commands, and fixing several bugs. The security review found no vulnerabilities. One issue was identified with the implementation of the ^ command's behavior on whitespace-only lines. Otherwise, the new features like d$, d0, dgg, u with counts, and Ctrl+[ for escape are great additions.

Align vim_move_to_first_nonwhitespace with standard Vim behavior:
on a whitespace-only or empty line, ^ should move the cursor to
column 0, not to the last character of the line.
@ppgranger
Copy link
Contributor Author

/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 is a fantastic pull request that significantly enhances the Vim mode with many much-needed features and fixes. The implementation of operators like d and c with various motions, along with correct count handling for commands like gg, D, C, and . is a huge improvement for Vim users. The code is well-structured, separating the Vim state management in the useVim hook from the text manipulation logic in vim-buffer-actions. I've identified a critical issue regarding Unicode character handling for cj and ck commands which could lead to data corruption, but otherwise, the changes are solid and the added tests are comprehensive. Great work!

ppgranger and others added 2 commits February 12, 2026 08:18
Rewrite cj and ck movement handlers to use direct array splice instead
of getLineRangeOffsets/getPositionFromOffsets. The previous implementation
used string.length (UTF-16 code units) for offset calculations, which
caused data corruption when lines contained Unicode characters like emojis.

The new implementation:
- Directly splices lines from the array, avoiding UTF-16/code point mismatch
- Properly handles edge cases (delete all lines, first/last line)
- Adds comprehensive tests including Unicode characters

Tests added:
- Unicode characters in cj (down) and ck (up)
- cj on first line of 2 lines (delete all)
- cj on last line (delete only current)
- ck on first line (delete only current)
- 2cj and 2ck from middle line
@ppgranger
Copy link
Contributor Author

/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 significantly enhances the Vim mode functionality, making it more complete and familiar for Vim users. It introduces numerous bug fixes and features, including correct handling of count prefixes for commands like gg, $, ., D, C, and implements missing commands such as u, d$, d0, and d+motions. The implementation is robust, well-structured, and thoroughly tested. No specific security vulnerabilities or issues of high or critical severity were identified.

@ppgranger ppgranger marked this pull request as ready for review February 12, 2026 08:50
@ppgranger
Copy link
Contributor Author

@jacob314 Ready for review :)

@scidomino scidomino self-requested a review February 12, 2026 21:50
Copy link
Collaborator

@scidomino scidomino left a comment

Choose a reason for hiding this comment

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

Solid work. I'm worried we are going to run into hotkey conflicts but I can't find any.

@scidomino scidomino enabled auto-merge February 12, 2026 22:42
@scidomino
Copy link
Collaborator

We have some test breakages. Please fix.

@scidomino
Copy link
Collaborator

Ah, you modified the keybindings but didn't run the update script to regen keyboard-shortcuts.md.

Please fix. Otherwise I will fix it for you eventually if I find the time.

@scidomino scidomino requested a review from a team as a code owner February 13, 2026 00:11
@scidomino scidomino added this pull request to the merge queue Feb 13, 2026
Merged via the queue into google-gemini:main with commit 5b48846 Feb 13, 2026
26 of 27 checks passed
@ppgranger ppgranger deleted the fix/vim-support branch February 13, 2026 03:26
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 priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ctrl-u does nothing in vi mode VIM does not support delete till end of line (d$) In VIM keyboard emulation mode, CTRL+[ does not act like ESC

2 participants