Friday, May 29, 2015

Re: Replicate TextPad feature (copy marked lines)

Hi Tim!

On Do, 28 Mai 2015, Tim Chase wrote:

> On 2015-05-28 13:54, skeept wrote:
> > He would use find with a string or regular expression. Then he can
> > mark all matching lines. He can repeat the process with several
> > strings.
> >
> > After that he would copy all the marked lines and paste to another
> > window.
>
> The common way to do this is to pull the matches into a register:
>
> :let @a='' | g/pattern/y A
>
> This will gather all the lines matching "pattern" into the "a"
> register which you can paste within vim
>
> :new
> "ap
>
> or assign to the system clipboard:
>
> :let @+=@a
>
> If you have multiple search terms, you can (as you mention) build the
> expression out of the gate (or incrementally thanks to Vim's
> command-line history):
>
> :let @a='' | g/pattern1\|pattern2\|pattern3/y A
>
> That is what I usually do when I want this functionality.
>
> If you want to build it incrementally by searching instead, you can
> use the search register, recall the previous search, and append your
> additional term
>
> /pattern1<cr>
> /<up>\|pattern2<cr>
> [repeat until you have all the terms you want]
> :let @a='' | g//y A
>
> There might be some plugins that simplify these actions, but under
> the hood they would likely do the same thing as this.

BTW: My NrrwRgn plugin provides the possibility to mark selected region,
open all selected regions in a new window and write all selected regions
back to its original buffer. This is not limited to a sinlge buffer, so
you can mark several regions in different buffers and write all at the
same time back

Disclaimer: Experimental feature, if it doesn't work for you, open an
issue at the plugin page


Mit freundlichen Grüßen
Christian
--
Ein Künstler, der schätzbare Arbeiten verfertiget, ist nicht
immer imstande, von eignen oder fremden Werken Rechenschaft zu geben.
-- Goethe, Maximen und Reflektionen, Nr. 1122

--
--
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/d/optout.

No comments: