Linux, plaintext & minimalism
June 30, 2020

How to copy text to the clipboard in Neovim

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.

Tags: Neovim | xclip


I don't have a commenting system simply because I haven't found a solution that I like. If you want to leave any feedback and/or have any questions feel free to contact me either via e-mail, the fediverse, by XMPP or by IRC (I'm Hund at freenode.net).