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 ?
When I use the yank command in vim, is the text saved into a buffer that is not visible to the user?
1 Answer
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'
-
1That's really interesting, I'll be sure to check it out. Thank you so much! Oct 16, 2022 at 16:42
-
-
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
:h registers
and:h clipboard
.