In vim, I select a text in visual mode, and type :w! ~/saved.txt
, actually vim will execute :'<,'>w! ~/saved.txt
. like this:
The command will save the text into ~/saved.txt
. In another vim instance, I can use :r ~/saved.txt
to read from ~/saved.txt
to the other vim.
This implement a global copy-paste on the same machine. I want to make this a vim-command/key-mapping, while I don't know how to implement it.
A simple key-mapping:
vnoremap ,w :w! ~/saved.txt<cr>
nnoremap ,r :r ~/saved.txt<cr>
Replace ,w
, ,r
with your favour.