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?
Asked
Active
Viewed 2,400 times
11
-
So you're on the host machine (OS X), have an open ssh connection to the guest (Linux), and you want to yank from vim on the guest to the host's clipboard, correct? – Two-Bit Alchemist Jul 10 '15 at 20:44
-
Yes that's exactly what I want – Leeren Jul 10 '15 at 21:01
-
windows: https://stackoverflow.com/questions/4313262/copying-stuff-from-vim-running-in-putty/4313348#4313348 – Ciro Santilli OurBigBook.com Sep 17 '17 at 23:10
1 Answers
9
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.

lcd047
- 5,731
- 2
- 28
- 38
-
1You can compile VIM with `+xterm_clipboard` easily with the solution posted here: http://stackoverflow.com/questions/10101488/cut-to-the-system-clipboard-from-vim-on-ubuntu – Cloud Jul 10 '15 at 20:56