solving my lazyvim copy & paste problem

Posted on by Mandla Mbuli

neovim clipboard

I am lazy, thus I use lazyvim instead of configuring neovim myself. I started out trying to configure vim and ultimately neovim. In that time I developed opinions and habits on how my editor should work. One of those habits is how the copy and paste work.

Vim has the concept of registers. When I copy something, it goes into a register. I can either explicitly tell vim which register I want it to use or it will you a default one depending on how the copying is done. When I copy something from an external source, it usually goes into the + register. I can then paste from that register.

I kept bumping into this in subtle ways. There is a simple way around it but it kept grinding at me. When I paste, I expect it to be within vim. LazyVim didn’t do this. It kept pasting things I copied somewhere else, then I had to go and copy again and paste. Just a paper cut that I come across just enough to be irritating but not irritating enough for me to do something about it. I just left it as a mental note for while. Until now.

Turns out the problem is the default setting that lazyvim uses for the clipboard option.

o.clipboard="unnamedplus"

Reading the neovim documentation for this:

To ALWAYS use the clipboard for ALL operations (instead of interacting with
the "+" and/or "*" registers explicitly): >vim
    set clipboard+=unnamedplus

Turns out I don’t want to ALWAYS use the clipboard for ALL operations. So I had to unset this:

o.clipboard=""

I just need to make sure that xclip is installed because neovim will search for that.

and that is one less papercut for me.


Mandla