Skip to content

vim: Add Helix jump-to-word support to Vim mode#55492

Open
GoldStrikeArch wants to merge 9 commits intozed-industries:mainfrom
GoldStrikeArch:feat/add-helix-jump-to-word-support-to-vim-mode
Open

vim: Add Helix jump-to-word support to Vim mode#55492
GoldStrikeArch wants to merge 9 commits intozed-industries:mainfrom
GoldStrikeArch:feat/add-helix-jump-to-word-support-to-vim-mode

Conversation

@GoldStrikeArch
Copy link
Copy Markdown
Contributor

@GoldStrikeArch GoldStrikeArch commented May 2, 2026

Closes #55481

Adds Vim-mode access to the existing Helix jump-to-word overlay via g z. We use g z because it is currently unassigned in Vim mode, while g w is already used for rewrap.

Most of the implementation lives in helix.rs because the existing jump overlay, label generation, and Helix/Vim modal behavior are currently intertwined there. This keeps the change small and reuses the existing navigation overlay logic instead of doing a broader refactor.

In Vim normal mode, jump labels behave like a cursor motion: selecting a label moves the cursor to the start of the target word without selecting it. In Vim visual mode, jump labels extend the selection like a Vim word-start motion, preserving Vim’s inclusive visual-selection behavior.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Added Vim-mode jump-to-word navigation on g z.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 2, 2026
@GoldStrikeArch GoldStrikeArch changed the title Feat/add helix jump to word support to vim mode vim: Add Helix jump to word support to Vim mode May 2, 2026
@GoldStrikeArch GoldStrikeArch changed the title vim: Add Helix jump to word support to Vim mode vim: Add Helix jump-to-word support to Vim mode May 2, 2026
@ksweetie
Copy link
Copy Markdown
Contributor

ksweetie commented May 2, 2026

I tested this and it works great, thank you!

In Vim visual mode, the behavior continues to extend the selection like Helix select mode.

I find this behavior surprising, but that might just be me.

@GoldStrikeArch
Copy link
Copy Markdown
Contributor Author

@ksweetie

I find this behavior surprising, but that might just be me.

What you behavior you would expect?

@SomeoneToIgnore SomeoneToIgnore added the area:parity/vim Feedback for Vim parity features label May 2, 2026
@ksweetie
Copy link
Copy Markdown
Contributor

ksweetie commented May 2, 2026

Caveat that I don't consider myself to be a vim expert. But I generally expect a motion to move the cursor to the same place whether in normal or visual mode. I'm playing around with various motions to try to find any that are different in the two modes. So far, I've only found $ to be slightly different.

  • $ (cursor ends up on the last character of the line)
  • v$ (cursor ends up one character past the last character, i.e. it includes the line break)

Otherwise, everything I've tried moves the cursor to the same position in both modes.

@GoldStrikeArch
Copy link
Copy Markdown
Contributor Author

GoldStrikeArch commented May 2, 2026

@ksweetie

a motion to move the cursor to the same place whether in normal or visual mode

I see, that makes sense. But from the practical perspective -> if you would put it to the same position as a "normal mode motion" (which is to the beginning of the word, like to the first character), is it actually what you want? Like usually you do it to delete text, etc, you would select the first letter of a word instead of the whole world (which does seem like a bad thing to me, but again I don't use Vim mode 😅 )

After some thinking:

  • commands like v w already do that (select the first letter after a movement). So, I guess Vim users are fine with that and this is indeed a desired behavior? 🤔

So, I updated the branch and it should behave similar to Normal mode now

@GoldStrikeArch GoldStrikeArch force-pushed the feat/add-helix-jump-to-word-support-to-vim-mode branch from 36c493a to 5cfaa47 Compare May 2, 2026 19:21
@ksweetie
Copy link
Copy Markdown
Contributor

ksweetie commented May 2, 2026

Ha, yeah those are interesting questions. I can definitely see the argument for wanting to select the word by default.

commands like v w already do that (select the first letter after a movement). So, I guess Vim users are fine with that and this is indeed a desired behavior?

I guess that's something I wouldn't do in practice. If I want to select the current word, I would do v e or v E. If I want to select the entire next word as well, then I would do something like v e e or v 2 e.

The only other relevant data point I can think of is that when you search with /, the cursor will land on the start of the search term in both normal and visual modes.

All that said, I think Conrad is the maintainer of vim in Zed. He'll have a much more informed opinion than me. Thanks again for adding this, I'm really excited for it!

@GoldStrikeArch GoldStrikeArch mentioned this pull request May 3, 2026
@ConradIrwin ConradIrwin self-assigned this May 5, 2026
@ConradIrwin
Copy link
Copy Markdown
Member

@GoldStrikeArch Thanks for taking a pass at this!

We already have sneak support, can we merge this and that?

What other vim plugins exist, and what shortcuts do they use (where did you get the idea for gz from?)

@GoldStrikeArch
Copy link
Copy Markdown
Contributor Author

GoldStrikeArch commented May 5, 2026

@ConradIrwin

We already have sneak support, can we merge this and that?

I am not sure that I am following, this one and sneak are a different things

What other vim plugins exist, and what shortcuts do they use (where did you get the idea for gz from?)

I checked out and easymotions, nvim.flash, nvim.leap and they use , s, S, f, F, T, so they kinda override the default motion with their version. I took g z just because it was not taken. It can be anything really, something like space + q? or some other "easy combo". Helix does use g w for it but it is taken in Vim mode

@niekdomi
Copy link
Copy Markdown
Contributor

niekdomi commented May 5, 2026

Just my two cents:

The afaik major jump plugins are

Differences

This PR

shows two labels at start of word. is a "vim port" of the helix jump (or whatever its called)

leap

You type s (or whatever key to start the search) and type two characters e.g., ti if you want to jump to t in action. After typing the characters, all matches of ti will receive a label. So if you want to jump to t in action you likely type something like stib. (This is at least how I understand a plugin, correct me if I'm wrong)

flash

You normally type s to go into search mode and start typing the word/position you want to jump to. All matches will get a label

Screencast.From.2026-05-05.09-21-52.mp4

they use , s, S, f, F, T, so they kinda override the default motion with their version

s/S aren't really required, since the same can be achieved with cl or cc. though ideally there is no default mapping ,similar to how its done for vim-sneak.

From the docs:

The Sneak motion feature allows for quick navigation to any two-character sequence in your text. You can enable it by adding the following keybindings to your keymap. By default, the s key is mapped to vim::Substitute. Adding these bindings will override that behavior, so ensure this change aligns with your workflow preferences.

@GoldStrikeArch
Copy link
Copy Markdown
Contributor Author

@niekdomi

I see, so those plugins have a different mechanics and purpose. The "amp jump" is a different meaning -> you get "prepared" labels, so you can jump to any word within the current view.

And this particular PR is just for Vim mode users to "get amp jump for free" because some users already tried to use it and it "kinda worked" but with Helix semantics (like the selection first) which can be somewhat easily adjusted.

@niekdomi
Copy link
Copy Markdown
Contributor

niekdomi commented May 5, 2026

this particular PR is just for Vim mode users to "get amp jump for free"

This is a good stopgap, but I think the real win would be enabling proper Flash/Leap navigation (maybe via a plugin). I'd love to see us move toward that rather than just settling for another jump-style alternative.

@GoldStrikeArch
Copy link
Copy Markdown
Contributor Author

the real win would be enabling proper Flash/Leap navigation (maybe via a plugin)

IMO it is much easier to do it directly here in the vim.rs rather than re-iterate on extensions API and expose the "host editor state", so you can scan the ranges, set/unset NavigationOverlay and so on. All of that can't be done right now from the extension and I guess maintainers would not want to expose all of that just for the Flash plugin (maybe I am wrong here)

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

Labels

area:parity/vim Feedback for Vim parity features cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants