0

This question already has an answer here:

I posted this question on StackOverflow first, as I did not know about "Vi and Vim beta".

How to augment Vim yank and paste, so when I yank, Vim writes the content to a file? When I paste, it uses the content from the file. I want to have a system wide file which serves as a global buffer.

Context: I run Vim in different tmux splits on a remote server (over ssh). I want seamlessly copy and paste between Vims in tmux splits. I tried a bunch of plugins, but none of them worked, thus the question.

marked as duplicate by statox Aug 23 '17 at 7:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • and the same question here, where do you get stuck ? what have you tried. Do you want to overwrite y and p ore have 2 new commands (YankToFile, CopyFromFile)? – Doktor OSwaldo Aug 23 '17 at 6:28
0

Use register +. For yanking use "+y which yanks to register + and for pasting use "+p which copies content from +.

I use the following maps in my vimrc to copy to system clipboard

noremap <leader>y "+y<CR>
noremap <leader>p "+p<CR>
  • use tmux,tmux buffer to unname register, uname register to tmux buffer github.com/tracyone/t-vim/blob/master/autoload/te/tmux.vim – tracyone Aug 23 '17 at 9:57
  • 1
    @c0de222 Using the + register does not work for copying between vims in different tmux splits, unfortunately. – ashim Aug 23 '17 at 17:20
  • @tracyone Can you please provide more details how to use the script? Somehow it did not worked out for me. I moved tmux.vim to ~/.vim/bundle/tmux.vim and "set runtimepath^=~/.vim/bundle/tmux.vim" . However, regular y and p did not paste between vims in tmux splits. – ashim Aug 23 '17 at 17:30
  • Alternatively, add these three mappings to your vimrc: vmap <C-c> :w! ~/.vbuf<CR>, nmap <C-c> :.w! ~/.vbuf<CR>, nmap <C-v> :r ~/.vbuf<CR>. – sente Oct 18 '17 at 9:12

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