VSCodeVim / VSCodeVim/Vim

Centering cursor while jumping to line doesn't work `42 z z`

Open
#9,567 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Describe the bug

In Vim when typing a line number (e.g. 42) and then z z makes it jump to that line and center the cursor vertically. I know I can use 42 g g to achieve the same effect, but my muscle memory wants to use z z for this. When pressed with no line number the z z command works great and centers the cursor vertically, it is just when a line number is given that it doesn't behave as in Vim.

I remapped z z to g g but now I can't center the cursor and instead the cursor will jump to the first line in the file (this is the way g g behaves which it makes sense), I'm not sure how expressive is the binding syntax but would appreciate if there's a way to achieve the desired effect.

To Reproduce

Open a long file, type a line number outside of the view, e.g. 100 z z, the cursor is centered within the current view but it doesn't jump to the 100th line in the file as it should.

Expected behavior

Typing 100 z z on a long file should move the cursor to the 100th line and center the cursor vertically.

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.30.1
  • VSCode version: 1.96.2
  • OS: Ubuntu 22.04 Linux x64 6.5.0-1019-oem

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing 100 z z in a long file with VSCodeVim 1.30.1 on the reported VSCode and Ubuntu versions, then compare it with 100 g g and plain z z. Trace the command or keybinding handling for a counted z z; done means the cursor moves to the requested line and centers vertically, while plain z z and existing g g behavior remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.