Skip to content

Change behavior of search with vim mode enabled#35157

Closed
viveksjain wants to merge 2 commits intozed-industries:mainfrom
viveksjain:vim_search
Closed

Change behavior of search with vim mode enabled#35157
viveksjain wants to merge 2 commits intozed-industries:mainfrom
viveksjain:vim_search

Conversation

@viveksjain
Copy link
Copy Markdown
Contributor

When vim mode is enabled, previously if Cmd-F (or platform equivalent) was pressed, enter will go to the editor's first match, and then hitting enter again goes to the next line rather than next match. This PR changes it to make enter go to the next match, which matches the convention in most other programs. The behavior when search is initiated with / is left unchanged.

Closes #7692

Release Notes:

  • Improved: In vim mode, if search is not triggered with / and instead a keyboard shortcut, hitting enter goes to the next match

Fixes zed-industries#7692. When vim mode is enabled, previously if `Cmd-F` (or platform equivalent) was pressed, enter will go to the editor's first match, and then hitting enter again goes to the next line rather than next match. This PR changes it to make enter go to the next match, which matches the convention in most other programs. The behavior when search is initiated with `/` is left unchanged.
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Jul 27, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @viveksjain on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@viveksjain
Copy link
Copy Markdown
Contributor Author

One thing I couldn't figure out is how is the rendering of search matches done in vim mode. In non-vim mode, it highlights the current match, but in vim mode even after this change, it only highlights the current line, but not the match within the line.

@viveksjain
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jul 27, 2025
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Jul 27, 2025

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

@ConradIrwin
Copy link
Copy Markdown
Member

@viveksjain In non-vim mode the selection is updated immediately as you type in the buffer, so the current result is selected, in vim mode this is not done.

I think we should probably also make that conditional, as it's pretty broken feeling when you can't see the current result right now.

@ConradIrwin
Copy link
Copy Markdown
Member

Closing for now, but feel free to re-open if you get time to work on this more

@viveksjain
Copy link
Copy Markdown
Contributor Author

Hi @ConradIrwin I don't think I have permission to reopen this PR so I created a new one at #51073, thanks! Every time I decide to take zed for another spin I get bothered by this issue :)

ConradIrwin added a commit that referenced this pull request Apr 1, 2026
When vim mode is enabled, previously if Cmd-F (or platform equivalent)
was pressed, enter will go to the editor's first match, and then hitting
enter again goes to the next line rather than next match. This PR
changes it to make enter go to the next match, which matches the
convention in most other programs. The behavior when search is initiated
with / is left unchanged.

This is a reopen of #35157, rebased and fixed.
Closes #7692

Release Notes:

- In vim mode, when search is triggered by the non-vim mode shortcut
(cmd-f by default) enter will now behave as it does outside of vim mode.

---------

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

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vim mode search should act like non-Vim mode when not triggered with /

2 participants