Wednesday, December 18, 2024

Re: Search anomaly?

On Wed, 18 Dec 2024, Arun E wrote:

> With a buffer having just..
>
> aaa
> bbb
> aaa
>
> ..and with the cursor on the first 'a' on the first line, when you search for 'aa', the hit on the first line -- the 'aa' starting at column 2 -- is not found, rather the cursor lands on the 3rd line. Is this a documented behavior? It is
> the same behaviour in vim 8 and 9. I have not tried other versions.
>
> Playing around on it a bit more, I kinda understand why. Vim seems to try to match the "aa" in the current position, and avoid the 'a' in column 2 for subsequent matches. A zero width pattern seems to hit all occurrences (\(aa\)\@=).
>

Yes, I see the same going back to vim74. Interestingly traditional ex-vi
behaves the same, while nvi jumps by each single "a" forward (which is
also confusing: on a line like this:
aaaaaa
and then searching for aa and hitting n
the cursor will move only by a single a forward, while I would expect it
to move by 2 "a")

I checked the POSIX specs, but it doesn't mention anything about it (or
I did not find it).

> Anyway, the current behavior is very confusing, perhaps should be
> documented if not done already.

It's hard to find and hard to understand, but :h cpo-c let's you
configure this.

Best,
Christian
--
"For the most part, Democrats don't question the Republican's right to govern
when they win elections"

Heck, Democrats don't question the Republican's right to govern even when
Democrats win elections.
-- Moopheus, on scienceblogs.com

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/Z2MrRq/NT2kNOoKA%40256bit.org.

No comments:

Post a Comment