0

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.

1
  • 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)?
    – B.G.
    Aug 23, 2017 at 6:28

1 Answer 1

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>
5
  • 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, 2017 at 9:57
  • 1
    @c0de222 Using the + register does not work for copying between vims in different tmux splits, unfortunately.
    – ashim
    Aug 23, 2017 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, 2017 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, 2017 at 9:12

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