VIM clipboard sharing between Mac OSX and remote Ubuntu server

Tested on Mac OSX El Capitan and Ubuntu 16.04

On the Mac side:

  1. Install XQuartz.
  2. Enable X11 clipboard syncing:xquartz_settings
  3. Make sure XQuartz is running before continuing. I also had to launch the terminal app within XQuartz and keep it running in the background.
  4. Launch iTerm or your terminal app of choice.
  5. SSH into your remote server with X11 forwarding enabled, e.g.
    ssh -X

On the remote side:

  1. Install a version of vim with xterm_clipboard support. To check:
    vim --version | grep clipboard

    If you see +xterm_clipboard, you’re good to go. Otherwise, on Ubuntu:

    sudo apt-get install vim-gtk
  2. Configure vim to alias the unnamed register to the + register, which is the X window clipboard. In your .vimrc, add:
    set clipboard=unnamedplus
  3. Start a new vim session and copy/paste should work between your local and remote machines.

Leave a Reply

Your email address will not be published. Required fields are marked *