Thursday, July 23, 2020

Re: Visual selection via :global

On 2020-07-24 04:43, Manas wrote:
> On Thu, Jul 23, 2020 at 05:57:51PM -0500, Tim Chase wrote:
>> On 2020-07-24 03:48, Manas wrote:
>>> Hi folks, I have a markdown file containing a couple of
>>> headings and some pointers as shown below.
>>>
>>> ```
>>> # Heading 1
>>> - pointer 1
>>> - pointer 2
>>> - pointer 3
>>>
>>> ## Heading 2
>>> - pointer 4
>>> - pointer 5
>>> ```
>>>
>>> I wanted to visual select all pointers only.
>>
>> Vim doesn't (to the best of my knowledge without hacky plugins)
>> support disjoint selections. That said, you don't mention what
>> you want to *do* with those lines once you've selected them.
>
> I want to yank those lines in order to paste somewhere else. In this
> particular case, I wanted to send it to someone.

Ah, the typical idiom here is to empty a register and then
yank-appending (yank into a capital-letter-named register) each of
the matching lines like

:let @a='' | g/^-/y A

This will gather all the matching lines into register "a" which you
can then either paste elsewhere, or transfer directly to your
system clipboard-register with

:let @+=@a

This lets you use any pattern you want to put matching lines on the
clipboard.

Hope this helps,

-tim

:help quote_alpha




--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200723184017.7d8166aa%40bigbox.attlocal.net.

No comments: