abhisek
abhisek

Reputation: 952

Sharing System Clipboard with vim under cygwin

I built a pretty good cygwin setup under Windows7. I installed vim under cygwin. Now, I can't share the system clipboard with vim. vim --version gives:

+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+xsmp_interact +xterm_clipboard -xterm_save

I tried setting set clipboard+=unnamed inside my .vimrc but it was no use. I tried P, "+p, *p and "*p but none of these pasted from the system clipboard. However, pressing SHIFT+Ins on cygwin prompt pastes from system clipboard. Am I missing something?

Upvotes: 4

Views: 2503

Answers (3)

1lOtzM291W
1lOtzM291W

Reputation: 470

Copy text from vim under cygwin, just press "key +key ykey in visual mode :

"+y

Paste text to vim under cygwin, just press " key +key pkey in normal mode :

"+p

Upvotes: 5

Alan Turing
Alan Turing

Reputation: 41

Cygwin uses /dev/clipboard to access windows clipboard. For copying in visual mode, you can just do something like:

:'<,'>w !cat > /dev/clipboard

In order to paste from a windows clipboard, you can do something like this:

:r !cat /dev/clipboard

I have been using this method for some time now without any issues. But it only works for console version of vim. Gvim for windows has + register which allows you to copy and paste from windows clipboard. So, it's as easy as "+y (copy) and "+p (paste).

Source: http://vim.wikia.com/wiki/Using_the_Windows_clipboard_in_Cygwin_Vim

Upvotes: 4

darcyparker
darcyparker

Reputation: 1219

Install the plugin fakeclip. This will enable the system clipboard behaviour to work in cygwin.

Upvotes: 1

Related Questions