word under cursor: yank/delete/use in command line?

0 views
Skip to first unread message

fka...@googlemail.com

unread,
Oct 8, 2007, 12:17:23 PM10/8/07
to vim_use
Hi,

I am curious if there are (possibly built-in) commands for these
tasks:

1) yank the *complete* word under the cursor (yw does work only if the
cursor is in the first pos of the word)

2) delete the *complete* word (like above)

3) paste the word under the cursor into the command line, e.g. as part
of a for a complex substitution (to evoid retyping it)

Thank You
Felix

Gary Johnson

unread,
Oct 8, 2007, 1:48:41 PM10/8/07
to vim...@googlegroups.com
On 2007-10-08, "fka...@googlemail.com" <fka...@googlemail.com> wrote:
> Hi,
>
> I am curious if there are (possibly built-in) commands for these
> tasks:
>
> 1) yank the *complete* word under the cursor (yw does work only if the
> cursor is in the first pos of the word)

yaw
yiw

The first yanks "a word" including trailing white space. The second
yanks the "inner word" not including trailing white space. See

:help text-objects

for more on these and other related text objects.

> 2) delete the *complete* word (like above)

The same principle applies, just the command is different:

daw
diw

> 3) paste the word under the cursor into the command line, e.g. as part
> of a for a complex substitution (to evoid retyping it)

As you type in the command line, type Ctrl-R followed by Ctrl-W to
insert the word under the cursor. See

:help c_CTRL-R_CTRL-W

for more on this and

:help c_CTRL-R

for other things you can insert into the command line.

Regards,
Gary

fka...@googlemail.com

unread,
Oct 8, 2007, 2:04:43 PM10/8/07
to vim_use
Thanks a lot.

Tony Mechelynck

unread,
Oct 8, 2007, 11:51:17 PM10/8/07
to vim...@googlegroups.com
fka...@googlemail.com wrote:
> Hi,
>
> I am curious if there are (possibly built-in) commands for these
> tasks:
>
> 1) yank the *complete* word under the cursor (yw does work only if the
> cursor is in the first pos of the word)

yiw
yank inner word (without the surrounding spaces or punctuation)

>
> 2) delete the *complete* word (like above)

daw
delete a word (with the surrounding space on _one_ side)

>
> 3) paste the word under the cursor into the command line, e.g. as part
> of a for a complex substitution (to evoid retyping it)

Ctrl-R Ctrl-W

see
:help objects
:help c_CTRL-R_CTRL-W

>
> Thank You
> Felix


My pleasure,
Tony.
--
"I am not an Economist. I am an honest man!"
-- Paul McCracken

Reply all
Reply to author
Forward
0 new messages