neovimyank

nvim yank reg keymapping customized


I am trying to simplify an operations yank to "+ reg.

default:In visual mode "+y

I'd go: <leader>y

I have set in my keymap.lua

keymap.set("i","<leader>y","\"+y")

but it doesn't work.

I have read the manual for keymap, but it is too heavy.


Solution

  • If you place "i" as the first argument in the keymap, it means you want to set a keybinding for insert mode, "v" for visual mode, and "n" for normal mode. You can also make keymap availabe in multiple modes, for example:

    So if you want to remap yanking try to do it in visual mode

    Paste command example:

    vim.keymap.set("n", '<C-v>', '"+p', { noremap = true, silent = true })

    Copy command example:

    vim.keymap.set("v", "<C-c>", '"+y', { noremap = true, silent = true })