How to paste into vims command line was asked here here. But how can I copy from the vim command line?
For example:
:python import sys; print(sys.executable)
Now I want to copy that line to the clipboard, for pasting it into an other editor.
How to paste into vims command line was asked here here. But how can I copy from the vim command line?
For example:
:python import sys; print(sys.executable)
Now I want to copy that line to the clipboard, for pasting it into an other editor.
You can assign to a register the content of another register:
:let @+ = @:
Will assign in the system clipboard (@+
) the last executed :
command (@:
).
However, this will become your last executed command. If you want to keep your python
command as the last one, you can do the following:
First open the command history:
q:
Go on the line of the command you want to copy, then yank it in the system register (visually selects the whole line and yanks it):
"+yy
This will copy the whole line with the new line character at the end, if you just want the command without the new line, you can do:
v$h"+y
Finally, close the command history:
:q
Yes, it is possible.
If you executed a command :foo
, the command text line will be stored in register :
, you can see it by :echo @:
.
To have those value in clipboard, you just let +
register have the same value.
So :let @+=@:
or call setreg('+',@:)
should help you.
q:
open command-line window, it's filled with command-line history, you can copy via "+yy
.