7

What is the difference between the clipboard and xterm_clipboard features? When do I need to enable one or the other at compilation time?

As an aside, how do these features relate to the mouse option? Is it only through the mouse middle button? I am using Vim from within the GNOME terminal.

1 Answer 1

5

I want to take a shot at answering my first question on this forum. If I understand your question right, you are referring to concepts of "clipboard" and "primary". If not - sorry, I am wrong.

Note: After the comment by @jjaderberg below, I decided to clarify why I assumed that xterm_clipboard in vim is Primary. To be sure I looked up Clipboard definition in xterm manual page. I was basically looking for other definitions of the word 'clipboard' in xterm context besides those explained below. Since I did not find anything, I made an assumption that xterm_clipboard in vim is Primary in X, since Vim's :help xterm_clipboard defines it as just:

+xterm_clipboard Unix only: xterm clipboard handling

Every X.org application (X window system implementation, as you know) has a shared copy/paste buffer called Primary. That's where xterm, rxvt and other X applications copy selection, which is cleared once you make another selection. You can see what is in your 'primary' by running:

xsel -p -o

This will print contents of your Primary buffer (note, xsel may not be installed by default). Another copy/paste buffer is called Clipboard, which is what you use when you do ctrl+c/ctrl+v. You can see what's in it:

xsel -b -o

In vim (on Linux at least), register * stores Primary and register + stores Clipboard. So if you make a selection in xterm and then in vim do "*p then you will insert what you selected in xterm. "+p will insert clipboard. (I think, if you copy something into clipboard you will clobber Primary, but I am not 100% sure, maybe someone can pitch in on this.)

I am not sure, how this relates to mouse, but I did notice that the visual selection that's done by mouse (with mouse=a) in vim in xterm also goes into * register and hence in Primary.

I also, can't answer for sure about default availability of this functionality, but I want to assume (after rebuilding vim7.4 many times) that in the vast majority of cases they are compiled in by default. If anyone has more input on this, please edit this bit too.

You can read more about this on Arch wiki.

Thanks for reading. Sorry, if I misunderstood. Hopefully, this helped a little. Cheers. :)

4
  • 1
    Welcome to vi.se! Your answer is correct, as far as I can tell, but I think the question specifically regards compiling Vim with or without particular features, and what the difference is between the Vim features clipboard and xterm_clipboard (see :help feature-list|/^clipboard\|^xterm_clipboard). If the primary and selection buffers are related to the Vim 'features' clipboard and xterm_clipboard, a note about this would be a valuable addition.
    – jjaderberg
    Aug 18, 2015 at 19:30
  • Thank you @jjaderberg. I agree, that's a miss on my end (about how xterm_clipboard relates to Primary). I looked up this particular term in :help xterm_clipboard in vim help as well, but from reading it inferred that this must refer to Primary. That may have been a wrong assumption. Then I looked at invisible-island.net/xterm/manpage/xterm.html (or man xterm) where I could not find any other definition of clipboard. So, I assumed that vim's "xterm_clipboard" must be Primary, which is why I wrote what it is. Let me put this assumption in the answer. Aug 18, 2015 at 19:40
  • Excellent, +1. I thought you were talking about the general difference between selection and primary, but with the last edit I understand how you relate these to the clipboard and xterm_clipboard Vim features. Links are good too (and if I may I will edit just to make the :help xterm_clipboard reference explicit).
    – jjaderberg
    Aug 18, 2015 at 19:52
  • Thank you @jjaderberg. Good edit and good job guiding me. Aug 18, 2015 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.