Bug/inconsistency in /\%'</ and/or /\%'>/ in linewise-vs-characterwise?

5 views
Skip to first unread message

Tim Chase

unread,
May 22, 2021, 3:55:48 PM5/22/21
to v...@vim.org
Coming up in this thread[1] on Reddit, I highlighted some text in
*characterwise* visual mode ("v") and hit <esc> to end visual mode.
With 'hls' set, issuing

/\%'<\_.\{-}\%'>/

properly highlighted the range as expected.

So then I highlighted some text in *linewise* visual mode ("V") and
hit <esc> and the highlight was removed. Using "n" to search for the
next match gave me an

E486: Pattern not found: \%'<\_.\{-}\%'>

which seems mistaken. Having done the linewise search, I can use

`<

and

`>

which both jump properly to the corresponding endpoints of the
linewise visual selection, so in theory the

\_.\{-}

should match everything in between (non-greedy). I tried prepending
both

\%#=1

and alternatively

\%#=2

to force the regex parsing engine, but both were equally unsuccessful
with linewise mode. So it doesn't seem to be some weird edge-case of
either engine.

AFAICT, the regex *should* work for linewise visual selections, but
for some reason doesn't.

Is this a bug? Or just my misunderstanding of something?

Thanks,

-tim



[1]
https://www.reddit.com/r/vim/comments/ninhe1/is_there_a_plugin_for_highlighting_text_under/


Bram Moolenaar

unread,
May 22, 2021, 6:26:03 PM5/22/21
to vim...@googlegroups.com, Tim Chase, v...@vim.org
I guess the problem is that the '> mark is at "MAXCOL". That means "at
the end of the line". But that position doesn't actually exist, so
searching for "\%'>" fails.

It probably works better when \%'> matches just beyond the last
character of the line, like /\n does. You can create an issue for that.

--
CUSTOMER: You're not fooling anyone y'know. Look, isn't there something
you can do?
DEAD PERSON: I feel happy... I feel happy.
[whop]
CUSTOMER: Ah, thanks very much.
MORTICIAN: Not at all. See you on Thursday.
CUSTOMER: Right.
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Tim Chase

unread,
May 22, 2021, 6:58:30 PM5/22/21
to Bram Moolenaar, vim...@googlegroups.com, v...@vim.org
On 2021-05-23 00:25, Bram Moolenaar wrote:
> Tim Chase wrote:
>> /\%'<\_.\{-}\%'>/
>>
>> So then I highlighted some text in *linewise* visual mode ("V")
>> and hit <esc> and the highlight was removed. Using "n" to search
>> for the next match gave me an
>>
>> E486: Pattern not found: \%'<\_.\{-}\%'>
>
> I guess the problem is that the '> mark is at "MAXCOL". That means
> "at the end of the line". But that position doesn't actually
> exist, so searching for "\%'>" fails.
>
> It probably works better when \%'> matches just beyond the last
> character of the line, like /\n does. You can create an issue for
> that.

That makes sense. Done:

https://github.com/vim/vim/issues/8238

(linking here just in case anybody else stumbles on this thread and
wants to follow along)

Thanks for looking into it.

-tim




Reply all
Reply to author
Forward
0 new messages