Ssh – How to copy and paste data between remote vps’vim and local vim

remotesshvim

Connect remote vps with ssh.

ssh user@vps_ip

Edit a file in remote vps with vim and write a line

some text

In normal mode ,press yy ,how to paste some text to my local'vim?
And vice versa.

1.GUI flavour of VIM
In local vim whose os is debian:

vim --version | grep clipboard
+clipboard       +job             +path_extra      +user_commands
+eval            +mouse_dec       +statusline      +xterm_clipboard

In remote vim whose os is debian:

vim --version | grep clipboard
-clipboard       +iconv           +path_extra      -toolbar
+eval            +mouse_dec       +startuptime     -xterm_clipboard

Can't install vim-gtk in remote vim.

sudo yum  install -y vim-gtk
No package vim-gtk available.

2.Does the local system have an X server?
Yes
3.Are you using a GUI login session on the local system?
Desktop in local os is LXDE,enter into GUI login session.

Best Answer

You can open the remote file by running vim scp://user@vps_ipi/remote_file and then open your local file with :e local_file, after that you can switch between the buffers with :bn and use the yy and p commands for copy and paste between the buffers.

I make a test opening a remote script, then copy all its content with ggVGy switched the buffer :bn and paste with P.