How to copy text to the clipboard in Neovim

Published: Tuesday, June 30, 2020

If you want to copy text to the clipboard in Neovim you can do so with xclip. The command is a bit complicated so I highly recommend you binding it to a shortcut.

This is what I have in my Neovim configuration to let me copy marked text using Ctrl+C:

vmap <C-c> y:call system("xclip -i -selection clipboard", getreg("\""))<CR>:call system("xclip -i", getreg("\""))<CR> 

Just make sure to install the tool xclip if you don’t already have it.



If you want to leave feedback you can do so by either sending me a message via e-mail or by commenting on my post for this article on the fediverse.