2

I've seen a guy (in a tutorial) pasting text, which he has copied (or yanked?) in a browser, in a file in vim. I was not able to reproduce this - I'm not very experienced in using vi or vim.

I can quote from this site:

Vim has extended vi to allow use of the * register as a reference to the system clipboard. So we can use normal mode commands like: "*dd or 1G"*yG to copy things into the * register and "*p to paste text from it.

So my question (slightly related is this one or this one, which I don't quite understand) is: how can I get access to any clipboard using vim in Fedora/Gnome?

:"*p

did not work for me,

:*p

neither.

Thanks!

Community
  • 1
  • 1
BairDev
  • 2,865
  • 4
  • 27
  • 50
  • `"*p` is a normal mode command: you are not supposed to use it in command-line mode. Since the command you use isn't supposed to do what you expect it to do it's hard to say if the issue is on Vim's side or yours or if there's even an actual issue. – romainl Oct 09 '14 at 08:25

2 Answers2

4

First, check whether your Vim has support for this: :version must include +clipboard.

On Linux, there's a distinction between the primary selection (register *) and the system clipboard (register +). See :help quoteplus for details. Best select / copy something and check the output of :register *+ whether it's there.

Finally, the way to get and put things from / to the clipboard in Vim is through the register name. For normal mode commands, that means prefixing "+ to the p (put) or y (yank) command, e.g. typing " + P. There's also an Ex command for command-line mode (which you've attempted), but this takes the register as an argument (and without the "): :put +

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • aha, :version gives me -clipboard . I'll check how to get it. – BairDev Oct 09 '14 at 09:23
  • You may only have the minimal Vim installed and need to get a `vim-full` or `vim-gnome` (or so) package installed. – Ingo Karkat Oct 09 '14 at 09:26
  • I'm afraid, I can't find the right package. So far I did: `[root@localhost ~]# yum list installed | grep vim vim-common.x86_64 2:7.4.417-1.fc20 @updates vim-enhanced.x86_64 2:7.4.417-1.fc20 @updates vim-filesystem.x86_64 2:7.4.417-1.fc20 @updates vim-minimal.x86_64 2:7.4.417-1.fc20 @updates` `yum` does not know `vim-gnome`, `yum search vi\*` didn't yield a result - do I have to use an rpm package from elsewhere? – BairDev Oct 10 '14 at 14:01
  • 1
    Try `vim-X11`, cp. http://superuser.com/questions/194747/how-to-install-vim-with-clipboard-support-on-fedora – Ingo Karkat Oct 10 '14 at 19:25
1

VIM 8.1.2269 with +clipboard & +xterm_clipboard enabled.

I do / Ctrl+r +

Jake A.
  • 13
  • 6