Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy from Vim visual mode to system clipboard

Tags:

vim

I want to copy text from visual mode into system (Ubuntu) clipboard. When I do ggVG to select everything in Vim, I can't seem to copy that into system clipboard.

Now I read several options on how to do this, but none of them works. For example this does not work: "+y or "+ or "*yy

Why is it not working?

like image 901
user3763437 Avatar asked Jun 22 '14 10:06

user3763437


People also ask

How do I copy and paste from clipboard in Vim?

When using Vim under Windows, the clipboard can be accessed with the following: In step 4, press Shift+Delete to cut or Ctrl+Insert to copy. In step 6, press Shift+Insert to paste.


1 Answers

You are probably using the default Vim. It's a lightweight build that lacks a number of features including clipboard support.

You can verify that with this command:

:echo has('clipboard')

O (zero) means "no clipboard support".

The simplest way to get clipboard support is to install a proper build:

$ sudo apt-get install vim-gnome

Then, you'll be able to do "+y and "+p.

See :help 'clipboard' for a way to synchronize Vim's unnamed register and your system clipboard.

like image 115
romainl Avatar answered Sep 23 '22 08:09

romainl