8

I'm currently switching to NeoVim using Mac, and unfortunately the yank key doesn't always work as I expect.

I currently use :%w !pbcopy to copy entire documents.

Is there any problem if I remap the yank key to something like !pbcopy? Do you have any tips for that?

2 Answers2

5

This tells vim/nvim to use the system clipboard for all yank, delete, change and put operations:

set clipboard=unnamedplus

I forget if this works on Mac. You might need to use unnamed instead of unnamedplus, or do something like this:

if has("unnamedplus")
    set clipboard=unnamedplus
else
    set clipboard=unnamed
endif
0

As mentioned in the comments to the other answer, non-macOS users will also need to ensure that the right clipboard tools are installed. You can view requirements via :h provider-clipboard. For example, for Linux + Wayland setup, you can install wl-clipboard. After logging out and back in, I was able to get a shared clipboard running with :set clipboard=unnamedplus in neovim.

Isa
  • 1