0

I would like to synchronize the system and nvim clipboards so I don't have to do anything extra to copy and paste. I want to do (since I am on MacOS) command c to copy and command v to paste, inside or outside of Neovim. I want to easily paste external text into Neovim, and copy Neovim text externally.

I am new to Neovim, so I may be missing some obvious fundamental concept.

I have tried all sorts of existing solutions. :put + is the most stable way to paste into nvim so far. Other ways (I have tried many) have pasted only part of the text, done nothing, or pasted just from the nvim internal clipboard. For copying, "+y works, but takes much longer to type compared to command c. I can't think of any reason I would want a separate clipboard within nvim, and I very commonly want the same keyboard within nvim.

3

2 Answers 2

1

:help map-cmd-key says:

The Super / Command modifier is available if the terminal or GUI supports it. The character "D" is used for the Super / Command modifier.

Add this to your init.lua:

-- Copy from visual mode. 
vim.keymap.set('v', '<D-c>', '"+y')
-- Paste in normal or in visual (to replace selection).
vim.keymap.set({'n', 'v'}, '<D-v>', '"+p')
-- Paste clipboard at cursor position from insert mode.
vim.keymap.set('i', '<D-v>', '<C-r>+')

Alternatively, you could try my vim-focusclip plugin that lets you use y and p -- even less typing!

0

As is well documented, you can use the 'clipboard' option to have the default register synchronized with either the + or * register by using the unnamed or unnamedplus values.

1
  • That was one of the first things I tried and it doesn't work for whatever reason
    – BigMistake
    Commented Aug 1, 2024 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.