Monday, January 27, 2014

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

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





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