1

I understand the concept of a buffer. It is the text that's saved from a file that we edit inside of vim. When I use the yy command, where exactly does vim save this information to? In any other editor, using the copy command would save it to the clipboard, so does vim have some kind of clipboard and would that clipboard also be called a buffer of sorts ?

3
  • 1
    Read :h registers and :h clipboard.
    – 3N4N
    Oct 16, 2022 at 15:57
  • confusingly, long ago, registers were also referred to as "buffers," sometimes "buffer registers" docs.freebsd.org/44doc/usd/12.vi/paper-6.html#section33
    – Mass
    Oct 16, 2022 at 16:29
  • 1
    In a different program, though, so no confusion possible unless you confuse the two programs.
    – romainl
    Oct 16, 2022 at 20:48

1 Answer 1

2

By default Vim saves the result into the " register and in the 0.

You can see the content of the " register using the command:

:reg "

Note: The 0 register is only used for the yank operation (i.e. not for the change or delete operation) this allow you to yank a text, delete the text you want to be replaced and past the yanked register using the "0p register.

If you want to have the yanked content into the system clipboard you have to make sure it goes into the * register.

You can do that by either:

  • Specifying the * register when you yank "*yy
  • Set the clipboard option to unnamed (:set clipboard=unnamed)

With the later:

  • Every yank, delete operation using the default register will set the clipboard (*) register
  • Every past operation using the default register will use the clipboard (*) register

More information about clipboard:

:help 'clipboard'
3
  • 1
    That's really interesting, I'll be sure to check it out. Thank you so much! Oct 16, 2022 at 16:42
  • Your are welcome. Thanks for the feedback :-) Oct 16, 2022 at 17:12
  • 1
    @Rich, I have added some remark about the 0 register. Let me know if you had other idea in mind. Oct 17, 2022 at 16:41

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.