Sunday, September 12, 2010

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

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

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

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