Vim copy-paste to system buffer not behaving as expected

buffercopy/pastevimx11

I'm having a headache trying to figure out why vim isn't copying to a system buffer.

Here's my workflow:

vim asd
y1y
:q
vim qwe
p

On computerA and computerB, this works as I want it to: the line yanked from the file asd is put into the file qwe.

On computerC, this doesn't work.

All systems are running Ubuntu 8.04. computerA has the vim-full package installed, computerB and computerC have the vim package installed. computerA has xorg installed, is using the fluxbox window manager, and is accessed locally. computerB and computerC don't have X, and I'm sshing into both of them.

I've done a lot of reading and thought it was because computerC was compiled with -clipboard, but I ran vim –version on all three computers and only computerA was compiled with +clipboard.

Am I missing something obvious? I believe the user's .vimrc and the global vimrc files are the same. I can post output of vim –version and contents of vimrc files if that would help.

Best Answer

Vim by default doesn't copy to a system buffer. The only way that it would remember the contents is if the multiple instances of vim use the same .viminfo file. It's possible that the .viminfo file isn't being written due to file permissions or due to a different setting in 'viminfo' (the option).

For more information on the viminfo configuration, see

:help 'viminfo'

To look at your current configuration on each computer, do:

:set viminfo?

As an aside, if you want to use the system clipboard (which must be present, so you'd need to do ssh -X), you can use:

:set clipboard+=unnamed

Then all copy and paste operations will use the X11 selection buffer. Of course, you need vim compiled with +clipboard for this to work, so it won't solve your immediate problem. See:

:help 'clipboard'

for more information.

Perhaps you could post the result of the following on each computer?

:set viminfo?
:set clipboard?

This would help us to diagnose the problem in more detail. Could you also try:

vim asd
"ayy
:q
vim qwe
"ap

This will use register a instead of the unnamed register.