How to copy text to the clipboard in Neovim

by Hund | 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.

Meta

Comments

There's no comments for this post. Use this e-mail form if you would like to leave a comment. [What's this?]