Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Nov 20 '12 at 19:54

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

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

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


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .