So I know with vimscript you could make paste not overwrite your register with this:

vnoremap p pgvy

And I've tried a few ways to get this to with with Lua such as:

vim.api.nvim_set_keymap('n', 'p', 'pgvy', { noremap = true })

But this doesn't work.

How can I get this kind of functionality with a Lua config?

  • 6
    FWIW, in modern vim :help v_P
    – D. Ben Knoble
    Aug 28 at 16:44
  • 2
    I second that recommendation :) Aug 28 at 18:00
  • Lol, well that's simple. Been wishing I could do this for years but just dealt with the "vp" functionality. Thanks!
    – Zach B.
    Aug 28 at 18:10

1 Answer 1


I believe you should do:

vim.api.nvim_set_keymap('v', 'p', 'pgvy', { noremap = true })

The first argument is the mode:

  • n for Normal (equivalent to nnoremap)
  • v for Visual (equivalent to vnoremap)

But as Ben suggested you could also do:

vim.api.nvim_set_keymap('v', 'p', 'P', { noremap = true })

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.