Monday, September 13, 2010

Re: How to copy the name of the variable / function under the cursor?

On Mon, Sep 13, 2010 at 08:27, Jürgen Krämer <jottkaerr@googlemail.com> wrote:
>
> Hi,
>
> Ven Tadipatri wrote:
>> On Sat, Sep 11, 2010 at 3:37 AM, caruso_g <peppecaruso@gmail.com> wrote:
>>>>   "+yiw
>>
>> I'm sorry - I'm not understanding what you're doing here. Wouldn't 'i'
>> put you into insert mode and then there would be a 'w' character
>> that's pasted.
>> Whever I want to paste, I just use 'P'.
>>    Thanks for the tip on the buffers - it looks quite useful.
>
> you should always try to read Vim commands from left to right; starting
> in the middle will often lead you astray. So let's check letter for
> letter:
>
>  " is used to address a register. The next letter is used as its name.
>    Lower-case letters are used to address "normal" registers. With
>    upper-case letters you can append to the corresponding lower-case
>    named registers. Numbered registers are used to store the result of
>    yank and delete commands. And some registers named by symbols are
>    used for special purposes.
>
>  + is the name of the register, in this case the register that is
>    connected to the clipboard.
>
>  y is the letter for the yank command. Unless used you are in visual
>    mode it must be followed by a movement or a text-object.
>
>  i is not a movement per se, but the start of a text-object. Together
>    with the next letter it will select part of the text without the
>    surrounding white space or, if you are already on white space, it
>    will select the white space.
>
>  w completes the text-object. Together with the i before it selects the
>    word under the cursor, which as a result of the whole command gets
>    copied to the clipboard.
>
> Regards,
> Jürgen
>

Thank you Jürgen! I mapped mp"+yiw`p to a function key and it is a
tremendous time saver. Your explanation was invaluable, I make a point
of understanding what I'm doing (both in the editor, and in the
code!), and not "just doing". Thanks!

Have a great week!

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

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

Post a Comment