Re: Search first character in a file
Doug Kearns <[email protected]> Thu, 22 Jan 2026 23:03:34 +1100
| Newsgroups | gmane.editors.vim |
|---|---|
| Message-ID | <CAJ1uvoDs5UVnTpQ1UkZLju5PA5Uh1+RVrAo1FjWB5mSzpQyufQ@mail.gmail.com> |
On Thu, 22 Jan 2026 at 02:21, Cristian <[email protected]> wrote: > > > Thank you for the explanation — that makes sense for the behavior of the n key. > > That said, I was wondering whether, for the initial search (the one > NOT triggered by n), it might also be reasonable for vi to start > searching from the character currently under the cursor. As others have pointed out, the behaviour is fundamental[1]. > This could make the behavior a bit more intuitive when the cursor > is already on a match. I think your intuition is incorrect. You wouldn't expect 'w', for example, not to move to the next word because the cursor was already at the start of a word. You can think of '/' as executing something like :let @/ = 'pattern' | normal! n The best solution, if you don't want to adjust to how it works, is probably to remap '/' to a user function that calls search('pattern', 'c') and sets the '@/' register. Anything else, like :-;/pattern, won't work well for multiple matches per line. Regards, Doug 1. https://pubs.opengroup.org/onlinepubs/9799919799/utilities/vi.html#tag_20_146_13_36 -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_use/CAJ1uvoDs5UVnTpQ1UkZLju5PA5Uh1%2BRVrAo1FjWB5mSzpQyufQ%40mail.gmail.com.