Saturday, July 7, 2012

Re: yank matched portion of a selection of lines

Am 07.07.2012 01:25, schrieb John Beckett:
> Hoss wrote:
>> Ideally, the yanked text would consist of each match within
>> the range, concatenated together with a newline between each.
>
> This does what you want (very useful!):
> http://vim.wikia.com/wiki/Copy_search_matches
>
> John

Somehow all of these solutions are less than ideal.

The best solution according to correct pattern matching involves
:substitute, but it modifies the buffer. You work around this problem
by creating a temporary buffer ...

I'd favor a solution with
:%s/{pattern}/\=CollectMatch(submatch(0))/gn

but '\=' and the "n" flag don't work together.
What about a todo item? Add another flag?

It's quite disappointing that just getting the matched strings (in a way
that is not a workaround) is so hard.

--
Andy

--
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

No comments: