Registers and the Clipboard

Recently I somehow ended up with set clipboard=unnamed in my .vimrc. I don't remember adding it, but I searched and removed it when I realised changes were overwriting my system clipboard contents. Here's what :help unnamed says, in case you're not familiar with this feature:

When included, Vim will use the clipboard register '*' for all yank, delete, change and put operations which would normally go to the unnamed register. When a register is explicitly specified, it will always be used regardless of whether "unnamed" is in 'clipboard' or not. The clipboard register can always be explicitly accessed using the "* notation.

Some people like set clipboard=unnamed. I find the "* register is way too frequently updated -- I prefer to think of the system clipboard as something that exists outside Vim, and keep Vim's registers as a separate bank of snippets.

If you're not sure how to paste from the system clipboard within Vim, then try "+p. I wrote about this in Vim 101: Registers, but in general just try to remember that registers are prefixed with a double quote and you can always view them with :reg.

blog comments powered by Disqus