Monday, January 27, 2014

Re: How to Move/Copy multi-line search matches?

Thanks for the tip Tim.

This (below) worked for me -
g/\cTable\s*\d\+:\_.\{-}\d\+\s*\n\ze.\{-}\%>75c.*/.,/\cTable\s*\d\+:\_.\{-}\d\+\s*\n\zs.\{-}\%>75c.*/-1m$

\_______________range________________/
range = current line[1] to the line preceding[3] the line which
matches the new search pattern[2]
[1] : .
[2] : \cTable\s*\d\+:\_.\{-}\d\+\s*\n\zs.\{-}\%>75c.*
[3] : -1

On Mon, Jan 27, 2014 at 5:48 PM, Tim Chase <vim@tim.thechases.com> wrote:
> On 2014-01-27 11:25, Sibin Thomas wrote:
>> I have a multi-line search pattern (
>> *\cTable\s*\d\+:\_.\{-}\d\+\s*\n\ze.\{-}\%>75c.**) which matches
>> multiple text segments in a file.
>> E.g. : One of the matched text segments -
>>
>> [image: Inline image 1]
>>
>> I would like to know how all the matched segments can be moved or
>> copied via a single operation.
>>
>> I am looking for something similar to 1)* :g/<pattern>/t$* 2)
>> *:g/<pattern>/m$ *3) *:g/<pattern>/y A,* except that it should work
>> for the entire multi-line text segment and not just the first line.
>
> Because you know that it will have at least the two lines, it
> simplifies matters a bit. You can specify a range to the command
> that :g executes, something like
>
> :g/{pattern}/{range}t
>
> which would make your command something like
>
> :g/\cTable\s*\s*\d\+:\_.\{-}\d\+\s*\n\ze.\{-}\%>75c.*/.;/\ze.\{-}\%>75c/t$
>
> \__________pattern_______________________________/ \_____range_____/
>
> -tim
>
>
>
>
>



--
Regards,
Sibin

--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: