Saturday, July 7, 2012

Re: yank matched portion of a selection of lines

Hi Andy!

On Sa, 07 Jul 2012, Andy Wokula wrote:

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

I have also wished for a something like this. I thought about patching
Vim and making the 'n' flag work with \= but I think it is just too hard
to prevent changes in the buffer.

Currently I am using the :%s/ approach for highlighting colors according
to their values in my Colorizer plugin, but that it modifies the buffer
and creates a new undo state is disturbing.

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

Would a textobject like i/ work?

regards,
Christian

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