neovide: I can't use the cmd+v to paste text on my mac;

Describe the bug I can’t use the cmd+v to paste text on my mac;

To Reproduce

  1. use cmd+c to copy something
  2. switch to neovide
  3. cmd+v to paste the text

Expected behavior paste the text to buffer/other

Screenshots

Desktop (please complete the following information):

  • OS: 12.3
  • Neovide Version 0.8.0
  • Neovim Version 0.7.0

Please run neovide --log and paste the contents of the .log file here:

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 24 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Based on @terhechte , I used this in init.lua:

-- Allow clipboard copy paste in neovim
vim.g.neovide_input_use_logo = 1
vim.api.nvim_set_keymap('', '<D-v>', '+p<CR>', { noremap = true, silent = true})
vim.api.nvim_set_keymap('!', '<D-v>', '<C-R>+', { noremap = true, silent = true})
vim.api.nvim_set_keymap('t', '<D-v>', '<C-R>+', { noremap = true, silent = true})
vim.api.nvim_set_keymap('v', '<D-v>', '<C-R>+', { noremap = true, silent = true})

I think having something that works out of the box (without the need to search the project issue tracking, copying mappings and so on) would be much better. cmd-v is the standard paste command on macOS. A GUI user shouldn’t care about keycodes, mappings and this kind of stuff unless doing something custom. Pasting should “just work” like in the rest of the OS.

@CG-man Actually, using <D-v> or <D-c> does nothing on macOS because this PR disables the command key. Took me way too long to figure this out as it isn’t really documented.

To enable Cmd + V / Cmd + P on macOS, I have these bindings:

" Allow copy paste in neovim
let g:neovide_input_use_logo = 1
map <D-v> "+p<CR>
map! <D-v> <C-R>+
tmap <D-v> <C-R>+
vmap <D-c> "+y<CR> 

Agreed with @metalelf0, as neovide is a GUI, I expect <kbd>⌘</kbd>+<kbd>v</kbd> to work. <kbd>⌘</kbd>+<kbd>v</kbd> already works in iTerm2 with neovim.

If a user has <kbd>⌘</kbd>+<kbd>v</kbd> mapped to something else, does that still work in iTerm/neovim?

The suggestions above are helpful, but don’t work in some situations (e.g., with fzf-lua, which was bothering me).

The most reliable (and correct imo) solution I’ve found is using vim.api.nvim_paste:

vim.keymap.set(
    {'n', 'v', 's', 'x', 'o', 'i', 'l', 'c', 't'},
    '<D-v>',
    function() vim.api.nvim_paste(vim.fn.getreg('+'), true, -1) end,
    { noremap = true, silent = true }
)

@MultisampledNight It would be nice if you would consider updating the documentation with something like this using vim.api.nvim_paste.

Fyi for people also stumbling upon this via a search, full solution here in the Docs :

if vim.g.neovide then
  vim.keymap.set('n', '<D-s>', ':w<CR>') -- Save
  vim.keymap.set('v', '<D-c>', '"+y') -- Copy
  vim.keymap.set('n', '<D-v>', '"+P') -- Paste normal mode
  vim.keymap.set('v', '<D-v>', '"+P') -- Paste visual mode
  vim.keymap.set('c', '<D-v>', '<C-R>+') -- Paste command mode
  vim.keymap.set('i', '<D-v>', '<ESC>l"+Pli') -- Paste insert mode
end

-- Allow clipboard copy paste in neovim
vim.api.nvim_set_keymap('', '<D-v>', '+p<CR>', { noremap = true, silent = true})
vim.api.nvim_set_keymap('!', '<D-v>', '<C-R>+', { noremap = true, silent = true})
vim.api.nvim_set_keymap('t', '<D-v>', '<C-R>+', { noremap = true, silent = true})
vim.api.nvim_set_keymap('v', '<D-v>', '<C-R>+', { noremap = true, silent = true})

We do have a PR open for updating the docs, but the problem is that it’s macOS specific

@shepherdjerred @i-am-the-slime My configuration is

if exists("g:neovide")
  let g:neovide_transparency=0.9
  let g:neovide_no_idle=v:false
  let g:neovide_fullscreen=v:false
  let g:neovide_remember_window_size=v:true
  let g:neovide_cursor_animation_length=0.1
  let g:neovide_cursor_antialiasing=v:false
  let g:neovide_cursor_vfx_mode = "torpedo"

  " mapping macOS shortcuts
  let g:neovide_input_use_logo=v:true
  map <D-v> "+p<CR>
  map! <D-v> <C-R>+
  tmap <D-v> <C-R>+
  vmap <D-c> "+y<CR>
endif

@suyby It just doesn’t work: NVIM v0.8.0 macOS 13

In addition, the value should be assigned like this.

vim.g.neovide_input_use_logo=v:true

So, the final configuration should be

init.vim

if exists("g:neovide")

  let g:neovide_input_use_logo=v:true
  map <D-v> "+p<CR>
  map! <D-v> <C-R>+
  tmap <D-v> <C-R>+
  vmap <D-c> "+y<CR> 

endif

@MultisampledNight So it is a bit of a Neovim issue because Neovim introduces a non-standard setting that disables the command key by default. Personally, I think this setting should be default-enabled on macOS. Would be willing to crate a PR for that.