Skip to content

fix(vim): respect count before gg (e.g. 5gg jumps to line 5)#13167

Open
Jason-Shen2 wants to merge 2 commits into
warpdotdev:masterfrom
Jason-Shen2:fix/vim-gg-count-line-jump
Open

fix(vim): respect count before gg (e.g. 5gg jumps to line 5)#13167
Jason-Shen2 wants to merge 2 commits into
warpdotdev:masterfrom
Jason-Shen2:fix/vim-gg-count-line-jump

Conversation

@Jason-Shen2

Copy link
Copy Markdown

Summary

Fixes #13132

In Vim, Ngg is equivalent to NG — both jump to line N. Previously, the gg motion always jumped to line 1 regardless of any preceding count, so:

  • 5gg jumped to line 1 instead of line 5
  • d5gg deleted up to line 1 instead of line 5
  • v5gg selected up to line 1 instead of line 5

Root Cause

In crates/vim/src/vim.rs, the gg key mapping (second 'g' after a pending G prefix) unconditionally returned VimMotion::JumpToFirstLine without checking for a pending count, unlike G which correctly uses get_action_count() / get_operand_count() to decide between JumpToLine(n) and JumpToLastLine.

Fix

Added a count check before falling back to JumpToFirstLine, matching the existing pattern used for G. The fix applies to all three modes where gg can appear:

  1. Normal mode (handle_normal_pending_action): uses get_action_count()
  2. Operator-pending mode (handle_normal_pending_operand): uses get_operand_count() (fixes d5gg, y5gg, etc.)
  3. Visual mode (handle_visual_pending_action): uses get_action_count() (fixes v5gg, V5gg)

A bare gg with no count still jumps to the first line as expected.

In Vim, Ngg is equivalent to NG — both jump to line N. Previously,
the gg motion always jumped to line 1 regardless of any preceding
count, so 5gg, d5gg, and v5gg all behaved as if no count was given.

This change checks for a pending count before falling back to
JumpToFirstLine, matching the existing handling for G. It applies
to normal mode, operator-pending mode (d5gg, y5gg), and visual mode
(v5gg, V5gg).

Fixes warpdotdev#13132
@cla-bot

cla-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: zhenxing.shen.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@oz-for-oss

oz-for-oss Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@Jason-Shen2

Every PR must be linked to a same-repo issue before Oz can review it.

This PR is linked to #13132, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jun 29, 2026

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Jason-Shen2

Every PR must be linked to a same-repo issue before Oz can review it.

This PR is linked to #13132, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

@acarl005

acarl005 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@Jason-Shen2 Please be sure to sign the CLA here as that is a legal requirement to accept your code

#13167 (comment)

After that you can run "/oz-review" and when the bot review passes, I'll take a look

@acarl005 acarl005 self-assigned this Jun 29, 2026
@cla-bot

cla-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Jason-Shen2 on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@Jason-Shen2

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Jun 30, 2026
@cla-bot

cla-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@Jason-Shen2

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot

cla-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vim: a count before gg is ignored (5gg jumps to line 1 instead of line 5)

2 participants