Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you yank to your local OSX clipboard in vim running on a remote Linux ssh session?

Tags:

vim

macos

ssh

I run linux via VirtualBox on OS X where I edit in vim. I do this by running my VM in a headless state and then sshing to the linux machine using port forwarding. Is there any way to yank text in visual mode so that what's yanked is put into my local clipboard?

like image 235
Leeren Avatar asked Jul 10 '15 20:07

Leeren


People also ask

How do I copy paste into terminal SSH?

hit Ctrl + V on the keyboard. use the keyboard to access the context menu's Edit > Paste option: Alt + Space , then E , then P. if the "Use Ctrl+Shift+C/V as Copy/Paste" option is activated, hitting Ctrl + Shift + V on the keyboard.


1 Answers

Make sure that (1) your Vims on both sides are compiled with +xterm_clipboard, and (2) you have X11 forwarding enabled through ssh. Then set clipboard to unnamedplus,autoselect in your vimrcs on both sides:

set clipboard=unnamedplus,autoselect,exclude:cons\\\\|linux

With this you should be able to yank text from a Vim on the guest and paste it to a Vim on the host, and the other way around, provided that the two Vims are running at the same time and the ssh connection is still open.

like image 75
lcd047 Avatar answered Oct 19 '22 14:10

lcd047