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

In a nutshell, I want the following:

  • y(ank) actually writes the yanked text to a line in a text file, maybe in your .vim directory
  • that line is prefixed with the name of the register, so "qyy yields q>my line of text
  • p(ut) gets the expected result from that file

The reasoning is to get more of a 'system wide' vim buffer to solve this problem:
Sharing Vim Yank Buffer

share|improve this question

I had the same question. I found following simple solution:

Edit your .vimrc file. Add the lines

map <C-y> <Esc>:'<,'>! cat \| tee ~/tmp/.myvimbuf<CR>

map <C-p> o<Esc>:.!cat ~/tmp/.myvimbuf<CR>

map <C-P> O<Esc>:.!cat ~/tmp/.myvimbuf<CR>

and make sure the directory ~/tmp is in place.

Open two instances of vim. If you now highlight a portion of text in one instance and hit CTRL+y and then hit CTRL+p or CTRL+SHIFT+p in the other instance, you should get what you want.

Obviously, the key combinations could be modified to whatever you like.

This needs cat and tee; it should work on any Mac/Linux machine.

share|improve this answer
ah, very nice. This would also allow paste while in insert mode. – gggg Jun 17 '11 at 15:47

All you really need is to use the viminfo feature. Put something like the following in your ~/.vimrc file.

set viminfo='20,\"90,h,%

Then butters, marks, and more are persisted between session automatically. See :help viminfo for more information.

share|improve this answer

You must log in to answer this question.

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