3

I ask a simple question: how to copy from a text file using vim,and paste to clipboard? If i use

yY

I can paste,but only on vim file(using p),on clipboard i can't paste content.

If i use "+Y paste nothing. How to paste content of file text copied with vim?

elbarna
  • 12,695

2 Answers2

3

You can use "+yy to copy a whole line to clibboard, which will allow you to paste it with ctrl+v somewhere else. You can also enter in visual mode (pressing v in normal mode) to select the exact text you want to copy.

Please note that you must have the +clipboard (and also python support +python if I remember well) in your compile flags enabled. To check this type: vim --version | grep clipboard

If you read +clipboard, you are good to go, othewise if it outputs -clipboard, then you need to recompile your vim with clipboard support (I had to do that as in my distribution they don't enable this by default).

Also, please consider addressing your questions to https://vi.stackexchange.com/, which is in beta right now, but can be a nice place for this type of question.

Kira
  • 4,807
1

This will depend on the flavor of vim; vim without clipboad support will need to call pbcopy (Mac OS X) or xclip or xsel (under X11) as a filter to move text into the OS clipboard, e.g. via :%!xsel -i -b to copy the whole buffer. This will wipe out the contents of the buffer (I use copycat to avoid that wiping problem, and to provide portability between Mac OS X and OpenBSD evironments), so a better option for most will be to use a vim with OS clipboard support.

thrig
  • 34,938