yanking a certain part of a line based on a regex (vim scripting)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

yanking a certain part of a line based on a regex (vim scripting)

meino.cramer
Hi,

I want to yank a certain part of a line (the cursor is positioned
on that line) from the position of the cursor to the point of the
line where a certain regex matches into a register. The target positon
is positioned on the right.

"into a register" is not the problem here ;)

I thought of something like

    :yt<regex>

but I didn't find a 't'-movement command, which allows a target
position defined by a regex.

Unfortunately a regex is needed here, since the target position cannot
be described with a single letter.

How can I acchieve this?

Thanks a lot for any help in advance!
Cheers
 Meino




--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: yanking a certain part of a line based on a regex (vim scripting)

Ben Fritz
On Thursday, March 2, 2017 at 9:31:13 PM UTC-6, [hidden email] wrote:

> Hi,
>
> I want to yank a certain part of a line (the cursor is positioned
> on that line) from the position of the cursor to the point of the
> line where a certain regex matches into a register. The target positon
> is positioned on the right.
>
> "into a register" is not the problem here ;)
>
> I thought of something like
>
>     :yt<regex>
>
> but I didn't find a 't'-movement command, which allows a target
> position defined by a regex.
>
y/pattern
(and then hit Enter to complete the search)

If you want to include the matched pattern as well:

y/pattern/e

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.