Saturday, January 12, 2013

Re: Yank part of line?

On Sun, Jan 13, 2013 at 1:29 AM, John Beckett <johnb.beckett@gmail.com> wrote:
> stosss wrote:
>> This appears to be the only thing in help that seems to imply
>> you can yank part of a line. But I can't figure out how to
>> make that work. Am I wrong about this? Is the only way to
>> yank part of a line in visual mode only or search and replace
>> if one gets technical?
>>
>> (text from :help y)
>
> An example of what is wanted would help make sense of this.
> Do you mean in a script?
> Yank which part of a line (how defined)?
>
> In normal mode, you can of course move the cursor to somewhere
> within the line and type y$ to yank to the end, or y0 to yank to
> the beginning, and lots more things.
>

An example could be in your reply above "move the cursor" I want to
put the cursor on "m" yank everything to "r" and I would do this in a
mapping and/or manually.

This came from :help y and it doesn't say anything about yanking lines
so I was thinking it is implying yanking part of a line. Doing y$ and
y0 is good but what about yanking something not at the beginning or
end of a line?

*y* *yank*
["x]y{motion} Yank {motion} text [into register x]. When no
characters are to be yanked (e.g., "y0" in column 1),
this is an error when 'cpoptions' includes the 'E'
flag.

I think I have a visual mode method that will work even in a mapping
where the visual selection is done by the mapping without any manual
selection before executing the mapping. In visual mode on the example
I used above from your line I would do on your line:

In normal mode, you can of course move the cursor to somewhere

^3fmv2tth"xy

The visual mode might be the best way unless that yank could be done
in normal mode.

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

No comments: