I want to make Neovim stop yanking the text I paste over into my register (mapped to system clipboard with vim.opt.clipboard = 'unnamedplus'), eg

If I have the text:


and I v over 'sdfgh', hit y, then go to the second line and v over 'as' and hit paste it will copy 'as' to my clipboard, I want it to keep 'sdfgh' instead


2 Answers 2


Just use P instead of p in visual mode. This will preserve the register.

To make this default, you can use a map such as

xnoremap p P
  • 1
    Will this not also make regular p behave like P (eg alter paste position etc ?)
    – Madoka
    Commented Nov 7, 2022 at 3:50
  • @Madoka xnoremap only affects Visual modes.
    – D. Ben Knoble
    Commented Nov 8, 2022 at 18:51
  • @d-ben-knoble Ah, okay Thank You !
    – Madoka
    Commented Nov 8, 2022 at 23:42

If you are using lua, update your keymaps.lua file to include:

-- mode
--  "n" - normal mode
--  "i" - insert mode
--  "x" - visual mode
--  "v" - visual and select mode

local function map(m, k, v)
    vim.keymap.set(m, k, v, { silent = true })

map("x", "p", "P")

This remaps p, which yanks text on paste with P, which doesn't yank text on paste.


  • oh, good idea! i ended up setting a remap for pgvy as p instead so it yanks back whatever the selected text before pasting was but this is a good idea too!
    – Madoka
    Commented Mar 3, 2023 at 2:17
  • this looks nice, but does not work for me. This worked vi.stackexchange.com/questions/25259/…
    – rofrol
    Commented Jul 15, 2023 at 23:54

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