copy a line/multiple-lines from vi editor to cmd line

A. K. picture A. K. · May 9, 2013 · Viewed 13.6k times · Source

Is there a shortcut key to copy a line from vi editor and then paste it into a terminal. Currently I select the text with mouse and then press crtl+shift+c (I'm using default settings of KDE) and then do ctrl+shift+v on the konsole. The problem with this option is when the line is long enough to wrap. In that case copy-paste inserts extra spaces which I have to fix after pasting on terminal.

This is very annoying specially when the line copied is very long and contains file names (typically commands used to invoke compiler).

Answer

FDinoff picture FDinoff · May 9, 2013

You can yank to the X clipboard by putting the contents in the * register.

To do this use "*yy on the line you want to yank. Then outside of vim you should be able to paste it.