Take the 2-minute tour ×

I am using Linux OS. I would like to copy some text in visual mode from Vim to system clipboard and then paste it in another shell. I tried the following :

In the .vimrc file inside /home/{USER} directory put the following :

vmap <C-c> "*y

After this I exited the shell and then opened a new shell and a file in vim. Did Visual selection and then issued *y. It yanked the lines selected. I exited vim and then in the shell issued CTRL+SHIFT+V . But nothing happens.

I tried setting the following also in .vimrc file :

set clipboard=unnamed

But this also doesn't work.

P.S: I am able to paste from system clipboard to vim using *p.

What can be the problem here? Am I setting the options in the wrong .vimrc file?

Edit: When I did vim --version|grep clipboard I see the following:

[subhrcho@slc04lyo ~]$ vim --version|grep clipboard
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
-xterm_clipboard -xterm_save 
share|improve this question

migrated from stackoverflow.com Apr 4 '13 at 18:31

This question came from our site for professional and enthusiast programmers.

This is the right ~/.vimrc. Try "+y and "+p instead. –  romainl Apr 4 '13 at 14:33
@romainl *p works for me already. –  Geek Apr 4 '13 at 14:36
Are you running vim within the terminal or the GUI version? What does vim --version | grep clipboard say? –  devnull Apr 4 '13 at 14:56
I can read, thanks. Can you answer my question? –  romainl Apr 4 '13 at 15:33

2 Answers 2

up vote 4 down vote accepted

On Linux, there's a difference between "* and "+. If you want to use the system clipboard (e.g. with Ctrl + Shift + V), you have to use "+. (Likewise, there's a :set clipboard+=unnamedplus in recent Vim versions.)

To paste the contents of "* in a terminal, use the middle mouse button.

Read more about this at :help x11-selection

share|improve this answer
@Igno I tried your suggestion. When inside Vim , if I do +y I see vim yanks some lines. And next I quit vim by :q! and then in the shell I do a right click, I see both copy and paste context menus are disabled. The CTRL+SHIFT+V also doesn't work. –  Geek Apr 4 '13 at 19:48
As per your edit, you first need to use a Vim that has clipboard support compiled in. Without that, you need to resort to external solutions like xclip. –  Ingo Karkat Apr 5 '13 at 6:38

No. You can't paste with "*p if Vim was not build with clipboard support.

-clipboard and -xterm_clipboard mean "no clipboard". Without clipboard support, "*y, "+y, "*p and "+p can't paste to/from the clipboard at all.

If you want clipboard support, you must get yourself a proper Vim build (vim-gtk for example). It's as simple as that.

share|improve this answer

Your Answer


