On Mon, Jan 14, 2013 at 10:53 AM, Charles Campbell
<Charles.E.Campbell@nasa.gov> wrote:
> stosss wrote:
>>
>> On Mon, Jan 14, 2013 at 8:45 AM, Tony Mechelynck
>> <antoine.mechelynck@gmail.com> wrote:
>>>
>>> On 13/01/13 08:15, stosss wrote:
>>>>
>>>> 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.
>>>
>>>
>>> 1) put the cursor on the m
>>> 2) to yank to the first r (the one in the middle of "cursor"):
>>> yfr
>>> 2a) or to yank to the second r (at the end of "cursor")
>>> y3e
>>> (i.e. "yank to the end of the 3rd word") or
>>> vfr;y
>>> see
>>> :help f
>>> :help e
>>> :help ;
>>>
>>> Or you could set a Visual mode highlight to whatever you wanted to yank,
>>> and
>>> just hit y (as in the last example above)
>>>
>>> Or to yank just the word "cursor" you could place the cursor anywhere on
>>> it,
>>> and then do
>>> yiw
>>> i.e. "yank inner word", see :help iw
>>>
>>>
>>>> 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.
>>>>
>>> It can: the y command (in Normal mode) expects a motion to tell it how
>>> far
>>> to yank. There are a lot of possible motions, see :help motion.txt
>>>
>>>
> Two more techniques:
>
> * start at 'm'. press ctrl-v . move to 'r'. press y
> * start at 'm'. press ma . move to 'r'. press y`a
>
> Regards,
> Chip Campbell
>
Thanks Chip
--
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
Monday, January 14, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment