Copying a word to command mode

1 view
Skip to first unread message

pravim

unread,
Dec 16, 2008, 10:41:51 PM12/16/08
to vim...@googlegroups.com
Hi, is there any way in VIM, where i can copy the word under the cursor to the command mode. ex. the cursor in vim is on the word "ThisIsABigFileName". i need some way so that "ThisIsABigFileName" is copied and when i press ":" to come to command mode; i can paste the copied word and proceed to do whatever. thanks, Pravin

View this message in context: Copying a word to command mode
Sent from the Vim - General mailing list archive at Nabble.com.

John Beckett

unread,
Dec 16, 2008, 11:39:57 PM12/16/08
to vim...@googlegroups.com
pravim wrote:
> Hi, is there any way in VIM, where i can copy the word under
> the cursor to the command mode. ex. the cursor in vim is on
> the word "ThisIsABigFileName". i need some way so that
> "ThisIsABigFileName" is copied and when i press ":" to come
> to command mode; i can paste the copied word and proceed to
> do whatever.

In the command line (after pressing ':'), press Ctrl-r then Ctrl-w, or
press Ctrl-r then Ctrl-a. See:
:help c_CTRL-R_CTRL-W

Also, you could select something, then press y to yank (copy) it. In the
command line, press Ctrl-r then " (double quote).

When fixed up, the tip for this is:
http://vim.wikia.com/wiki/Word_under_cursor_for_command

John

pravim

unread,
Dec 16, 2008, 11:48:17 PM12/16/08
to vim...@googlegroups.com

awesome....thanks,

but what is the difference if i use CTRL-r + CTRL-r or CTRL-r + CTRL-a ?

both appear to do the same thing!!!

Pravin
--
View this message in context: http://www.nabble.com/Copying-a-word-to-command-mode-tp21046590p21047144.html

Tony Mechelynck

unread,
Dec 17, 2008, 12:02:38 AM12/17/08
to vim...@googlegroups.com
On 17/12/08 05:48, pravim wrote:
>
> awesome....thanks,
>
> but what is the difference if i use CTRL-r + CTRL-r or CTRL-r + CTRL-a ?
>
> both appear to do the same thing!!!
>
> Pravin

Ctrl-R Ctrl-W selects a word, i.e., only 'iskeyword' characters.
Ctrl-R Ctrl-A selects a WORD, i.e., anything that isn't a space, tab or
linebreak.

Ctrl-R Ctrl-R is something else; it modifies the Ctrl-R to make it
literal. What it actually does depends on the next key you hit. See
":help c_CTRL-R_CTRL-R" for clarification.


Best regards,
Tony.
--
"Always try to do things in chronological order; it's less confusing
that way."

John Beckett

unread,
Dec 17, 2008, 1:41:01 AM12/17/08
to vim...@googlegroups.com
pravim wrote:
> but what is the difference if i use CTRL-r + CTRL-r
> or CTRL-r + CTRL-a ?
>
> both appear to do the same thing!!!

A generic answer is to work out how to follow the help topics. At ':help
c_CTRL-R_CTRL-W' that I mentioned, we also see CTRL-P. Once used to
Vim's help, you would realise that it's talking about essentially the
same as CTRL-F, so you would follow the 'gf' link (double click if that
is enabled; I would move cursor to 'gf' then press Ctrl-] (and later,
Ctrl-t to return). That leads you to half the answer at 'isfname' (the
other half is likewise found by following links on the original page).

John

Reply all
Reply to author
Forward
0 new messages