Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My goal is to yank a line in the shell (for example with yy) into the system clipboard and then paste it somewhere else (for example in the internet browser). How can I accomplish that?

share|improve this question

migrated from stackoverflow.com Nov 20 '12 at 19:54

This question came from our site for professional and enthusiast programmers.

1  
vi doesn't know about the GUI's clipboard, but the terminal emulator you run it in does. Use the terminal emulator to highlight the line and copy it into the clipboard. –  antlersoft Nov 20 '12 at 17:28
    
AFAIK, bash's vi mode deals only with what is currently at the prompt. Do you want to yank what's currently at the prompt or some previous text from a previous command? –  romainl Nov 20 '12 at 22:02

2 Answers 2

The simplest way to get the end result you want (pasting code from shell to internet broswer) is to:

  • Select the text with your mouse cursor
  • Ctrl+Shift+C to copy
  • Ctrl+V to paste outside of terminal
  • Ctrl+Shift+V to paste into a terminal prompt
share|improve this answer
3  
Note this is not universal - some terminals will support it, others use different hot-keys, and yet others won't do it at all, but will allow you to select/copy/paste with mouse actions. Better answer is to check the documentation for the terminal emulator you are using... –  twalberg Nov 20 '12 at 17:58

Your vim need have *+xterm_clipboard* flag, you can check this with vim --version | grep +xterm_clipboard. If your vim isn't compiled with this flag, you can compile it yourself or try to install gvim (usually it comes with this flag).

For access to the system clipboard you have to type those sequences:

  • Copy (a word): "*yw
  • Paste: "*p

See: http://vim.wikia.com/wiki/Accessing_the_system_clipboard

share|improve this answer
1  
He's not trying to copy & paste from vim, but from bash, using its vi key-bindings. –  tink Nov 20 '12 at 19:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.