On 05-Jun-2013 13:56 +0200, Andy Wokula wrote: > Am 05.06.2013 08:56, schrieb Ingo Karkat: >> On 05-Jun-2013 08:03 +0200, Christian Brabandt wrote: >> >>> [...] the old engine has an long standing bug with \%V ;( >>> >>> e.g: >>> >>> vim -u NONE -N >>> ifoobar<esc> >>> 0ve<esc> >>> /\%Vfoobar\%V >>> >>> I should have probably provided a fix long ago. >> >> Where is the bug, that there's no match?! That's intended, as the last >> \%V matches zero-width _after_ the end of "foobar", but the visual >> selection ends on the "r". You'd have to use /\%Vfooba\%Vr here. (The >> example at :help \%V is wrong about this corner case, too.) >> >> The general case is this ugly beast: /\%Vfoobar\%(\%V\|\%(\%V.\)\@<=\). > > Keep it simple ...: > /\%Vfoobar\%(\%V.\)\@<=
You're technically right, maybe it was irrational fear of bad performance (from the help: "For speed it's often much better to avoid this multi.") that made me introduce the branch for the common case. Confession: I've never measured this, though. > (Any actual use case for the /ugly beast/?) As I've mentioned, when you don't have a hard-coded "foobar", but a passed regular expression e.g. in a custom command. >> Since restricting the match to inside the entire selection is such a >> common use case (see the related vis.vim plugin), I think it would be >> worthwhile to have a special atom (e.g. \%<V) that matches if the >> _preceding character_ is inside the selection, allowing this much nicer >> pattern: /\%Vfoobar\%<V > > Looks like \%<V would be the same as \%(\%V.\)\@<= Right, but hopefully with better performance. The main benefit would be that it's easier to remember and type. Bram has just suggested a generic \@0<= elsewhere in this thread, but I think even that (\%V\@0<=) would be too hard to remember. -- regards, ingo -- -- You received this message from the "vim_dev" 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_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
