I wanted to copy some code I have from Neovim to Firefox, but the stuff I yanked doesn't carry over outside Neovim.
After I checked :checkhealth
, this what it said:
What should I do to handle this issue?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityIn order to be able to paste text copied from Neovim to any app, you have to copy the text to the system clipboard. You can do that as follows:
Install a clipboard tool, because in your screenshot it is shown that you don't have one installed.
If you are on a Xorg session, you may install either xsel
or xclip
by running:
sudo apt install xsel
or:
sudo apt install xclip
If you are on a Wayland session, you may install wl-clipboard
by running:
sudo apt install wl-clipboard
Select the text you wish to copy in Neovim.
Press the following keys one at a time: "+y
This copies (y
) the selected text to the selection register ("+
).
Paste the selected text to the app you wish to using the usual paste shortcut Ctrl+V.
To make things easier, you can also have the text you copy in Neovim always copied to the system clipboard by adding the following in your ~/.config/nvim/init.vim
file (create the file if it doesn't exist or go to the correct file location if you use a custom Neovim setup):
set clipboard=unnamedplus
x
is often tightly coupled with X11, does that change the answer in any noteworthy way? I'm no expert on this subject, but carrying clipboard information between windows seems like exactly the kind of thing that might be very different between the two.
xsel
and xclip
work on X11 only. wl-clipboard
should work for Wayland. I have updated my answer. Thanks for your comment!
Sep 25 at 9:20
I just tested my nvim and my Copy/Paste/Mouse related config options from (~/.config/nvim/init.vim) are:
set mouse=nv " middle-click paste with
set hlsearch " highlight search
set clipboard+=unnamedplus " using system clipboard
# with these plugins
call plug#begin("~/.vim/plugged")
" Plugin Section
Plug 'dracula/vim'
Plug 'ryanoasis/vim-devicons'
" Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'scrooloose/nerdtree'
Plug 'preservim/nerdcommenter'
Plug 'mhinz/vim-startify'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
Now Copy works by double-clicking or clicking+draging the mouse to highlight your text selection, right-click then brings up a mini-menu with Copy, Paste, Etc. Select Copy.
Now all of 1) middle-clicking, 2) right-clicking for the mini-menu again to select Paste & 3) the old staple option Ctrl+v will perform the Paste both inside another xfce4-terminal using nvim on a text file or using Firefox on Ask Ubuntu to do this.
And Yeah, I saw the above post, I have xsel 1.2.1-1 installed. If you need my entire nvim/init.vim config file just let me know. Cheers, Jono