2

My Vim is installed with +clipboard support, and all works just fine.

I know that the clipboard comes with X, so there isn't such a thing in a virtual console (or, at least, this is what I've understood), but...

By pure curiosity, I've just opened Vim in a virtual console (one of those you can get to via Ctrl+Alt+Fn for n generally from 1 to 5, iirc, as 7 is likely where you are running your desktop env) and verified that yanking stuff into the + register is also automatically stored in the * register, and viceversa, because whatever I yank into one, then putting from either of them results in that text. To give an example, given the text

one
two

and the cursor being on the first line, hitting "+yyj"*yy"*p"+p results in

one
two
two
two

and the same happens even if I invert the first + and the first *.

However, :registers doesn't actually list any of the two.


To give some gratuitous context which could incidentally help you understand the reason of my question, is that I noticed the + and * registes don't work in freshly installed Archlinux system where I've installed Vim with +clipboard support and to which I connect via ssh. I have eventually remembered that for the +clipboard to be useful and working across SSH, one has to connect via ssh -X (or even ssh -Y). But apparently that is not enough on this new system I'm referring to. I've asked a question on Unix.StackExchange as well.

2
  • 1
    After pasting ("+p), :display shows the contents of " and 0 registers to be what I copied into + or * register. Interesting.
    – 3N4N
    Sep 25, 2022 at 15:05
  • 2
    I don't know about 0, but " is basically a pointer to the most recently used register, so that's normal.
    – Enlico
    Sep 25, 2022 at 15:08

1 Answer 1

1

Even though it doesn't show in the output of :display, when you use the plus or star registers in TTS (i.e., a mode without clipboard feature), it stores the content in the 0 register. The code is in the get_yank_register function.

If we see the else condition, which is what gets executed in TTY mode for star and plus register (I double-checked with gdb), we'll see it sets the register being handled to 0.

else        // not 0-9, a-z, A-Z or '-': use register 0
    i = 0;

The same is true when you're pasting the content (the argument writing is false in that case, everything else is the same).

Why the 0 register doesn't display it until it is pasted into a buffer is still a mystery to me. I'll look around and update this answer if/when I find that answer.

Your Answer

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

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