zed icon indicating copy to clipboard operation
zed copied to clipboard

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

Open shinebayar-g opened this issue 1 year ago • 20 comments

Summary

When searching with / in Vim mode, hitting enter moves the cursor to the next line in the buffer being searched, matching Vim's behavior. This is at odds with how enter behaves in a non-Vim-mode buffer search, jumping to the next result. We should refine the action here to behave like non-Vim mode unless / is used to start the search.

![image](https://github.com/zed-industries/zed/assets/3091558/31209340-78b2-44bf-bd49-bf19681b973c)

shinebayar-g avatar Feb 12 '24 16:02 shinebayar-g

Hey @shinebayar-g! I cannot reproduce this. When I search in the buffer and the search input is focused, enter gets me to the next search result.

See here: https://github.com/zed-industries/zed/assets/1185253/ec3eb75e-0464-43bd-b52f-03f4b6b330ca

Or do you use Vim mode by any chance?

mrnugget avatar Feb 13 '24 13:02 mrnugget

Or do you use Vim mode by any chance?

The enable vim-mode same will enter new lines

demo

d1y avatar Feb 13 '24 13:02 d1y

Or do you use Vim mode by any chance?

Hey @mrnugget , thanks for the hint. I noticed that It's only reproducible in Vim mode.

shinebayar-g avatar Feb 13 '24 15:02 shinebayar-g

Okay, I see. But where does this expectation come from? As far as I know (and I just checked again): by default Vim doesn't bind <enter> to go-to-next-search-result. It's bound to n and <cr> is equivalent to ctrl-m.

mrnugget avatar Feb 13 '24 15:02 mrnugget

yeah 😞

shinebayar-g avatar Feb 13 '24 15:02 shinebayar-g

Okay, I see. But where does this expectation come from? As far as I know (and I just checked again): by default Vim doesn't bind <enter> to go-to-next-search-result. It's bound to n and <cr> is equivalent to ctrl-m.

And. The shift-enter useful in vim-mode (prev-result)? If so, it would be more intuitive to bind enter to the search input(box)

d1y avatar Feb 13 '24 15:02 d1y

I still can't reproduce this. When I search in Vim mode with / and then hit <enter> I only jump the next line, just like in Vim.

https://github.com/zed-industries/zed/assets/1185253/b30ef37c-70ac-485a-a7a5-32353dc01dfd

mrnugget avatar Feb 13 '24 15:02 mrnugget

I still can't reproduce this. When I search in Vim mode with / and then hit <enter> I only jump the next line, just like in Vim. screenshot-2024-02-13-16.49.37.mp4

You beat me to it 😄 . Try the same when you're in INSERT mode.

shinebayar-g avatar Feb 13 '24 15:02 shinebayar-g

I still can't reproduce this. When I search in Vim mode with / and then hit <enter> I only jump the next line, just like in Vim.

screenshot-2024-02-13-16.49.37.mp4

Disable all my custom keymap and use "/" + "cmd+shift+f" <enter> not work

vim-mode "n" / "shift-n" prev/next result it work

sb.gif

d1y avatar Feb 13 '24 15:02 d1y

Okay, so you want to work like in non-vim-mode when you trigger a search through cmd+f/cmd-shift-f even though you're in Vim mode, yes?

mrnugget avatar Feb 13 '24 15:02 mrnugget

Yeah I would be glad if certain base functionalities work the same across vim/non-vim modes.. Like search.

shinebayar-g avatar Feb 13 '24 16:02 shinebayar-g

I think that when the search-input is focused, triggering enter should trigger an operation (such as next-result), rather than unfocus and jump to the result. This is not in line with the habits we have developed using other applications.

d1y avatar Feb 13 '24 16:02 d1y

I think that when the search-input is focused, triggering enter should trigger an operation (such as next-result), rather than unfocus and jump to the result. This is not in line with the habits we have developed using other applications.

I personally prefer that, because it's exactly how it works in Vim: you start a search with /, you finish it by hitting enter, you jump to the next search results with n/N. That's at least the habit I've developed over a decade of using Vim :)

But I think the solution here would be to change the behaviour depending on whether the search was started via cmd-f or via /.

mrnugget avatar Feb 13 '24 16:02 mrnugget

I'm just wondering why 'shift enter' works. Is this bug?

fix

The default bind image

d1y avatar Feb 13 '24 16:02 d1y

This is what I wanted to say. There is a difference between searching in NORMAL vs INSERT mode. NORMAL mode works as expected. return key jumps to the next result. In INSERT mode it doesn't. It inserts new line instead.

https://github.com/zed-industries/zed/assets/3091558/efba782a-5c60-416d-bd18-ce063181beb3

shinebayar-g avatar Feb 13 '24 16:02 shinebayar-g

Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. Are you able to reproduce this issue in the latest version of Zed? If so, please let us know by commenting on this issue and we will keep it open; otherwise, we'll close it in a week. Feel free to open a new issue if you're seeing this message after the issue has been closed. Thanks for your help!

github-actions[bot] avatar Sep 24 '24 13:09 github-actions[bot]

Still an issue

viveksjain avatar Sep 24 '24 18:09 viveksjain

Can this issue be re-evaluated? Without enter working, ctrl+f is kind of useless. Whenever I press enter it just moves cursor to the next line instead of jumping to the next match.

Clicking n to navigate to the next match works only if the find bar is not in focus. If the find bar is still in focus it adds n to the search input. So UX around is not so great.

shinebayar-g avatar Nov 12 '24 16:11 shinebayar-g

Hi there! 👋 We're working to clean up our issue tracker by closing older bugs that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and it will be kept open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, it will close automatically in 14 days. Thanks for your help!

github-actions[bot] avatar Nov 19 '25 07:11 github-actions[bot]

Still an issue

viveksjain avatar Nov 22 '25 17:11 viveksjain