1

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:

:checkhealth output

What should I do to handle this issue?

2 Answers 2

3

In 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:

  1. 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
      
  2. Select the text you wish to copy in Neovim.

  3. Press the following keys one at a time: "+y

    This copies (y) the selected text to the selection register ("+).

  4. 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
3
  • this worked, thank you so much.
    – Vegeto.T
    Sep 24 at 20:15
  • 1
    Given the slow, but steady advance of Wayland (and how it has picked up a lot of steam recently), and me being wary that a piece of software beginning with 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.
    – Arthur
    Sep 25 at 9:05
  • 1
    @Arthur I think that the only change should be the clipboard command to be used. 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
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .