tags:

views:

646

answers:

3

How to copy the ex command to the clipboard or paste it to the buffer?

Using gvim on Windows.

+6  A: 

The windows clipboard can be accessed through the buffer +. So pasting your clipboard as an ex-command can be done with <C-R>+. If you want to copy your ex-commands to the clipboard, you need to show the command history (q:) and copy it into the clipboard buffer ("+yy).

soulmerge
<C-R>+ works to paste into the ex-command line.But How do I copy the ex-command into the clipboard?
Ayman
I presume you can reach command history with q:from normal mode or <C-F>from ex-command mode. (:<C-F>)
Maxim Kim
Aaah. Didn't know about the ex-history window. Exactly what I need.
Ayman
My bad, It's q:, not q!: Corrected the answer (thx Maxim)
soulmerge
A: 

If you source mswin.vim in your setup it will map the default Windows copy/paste keys to use the clipboard. If you want to do it yourself please see Soulmerge's answer.

Brian Rasmussen
Problem is that I cannot select the command to copy it. I use the mouse to select, and then that works, but it's not really the vim way.
Ayman
I'm not sure I follow. Normal move commands work with yank. If you want something more fancy, you can use visual mode (v/V)
Brian Rasmussen
I didn't know about the ex-command history Window. SO it did not make sense at first. Now it it does.
Ayman
+3  A: 

Enter command history with (from normal mode)

q:

Then select and copy(yank) commands you need with

"*y
Maxim Kim