Pergunta

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).

Foi útil?

Solução

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.

Outras dicas

If you don't have access to a clipboard via X or screen or tmux, you can write the contents of the buffer to a temp file, then go to the terminal and invoke $(cat temp-file) or open an editor for the command line and read in the file. Whatever shell you are using probably provides a mechanism for opening an editor on the command line. In bash with vi-style readline keybindings you can type v to get a vi session. If you shell does not provide that functionality, try a different shell.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top