ThePrimeagen/init.lua

Suggestion to replace your greatest remap ever

Opened this issue · 0 comments

Was looking at your maps and saw:

-- greatest remap ever
vim.keymap.set("x", "<leader>p", [["_dP]])

I think you would get a lot value out of:
https://github.com/vim-scripts/ReplaceWithRegister

Its the plugin I use the most, and think it should be built into VIM as a default text motion.

In your case you could do something like:

vim.keymap.set('n', '<leader>p', '<Plug>ReplaceWithRegisterOperator', {})
vim.keymap.set('n', '<leader>P', 'Plug>ReplaceWithRegisterLine', {})
vim.keymap.set('x', '<leader>p', '<Plug>ReplaceWithRegisterVisual', {})

From the help file:

-- REPLACE WITH REGISTER
-- https://github.com/vim-scripts/ReplaceWithRegister
-- https://www.youtube.com/watch?v=wlR5gYd6um0#t=26m49
-- [count]["x]gr{motion} = Replace {motion} text with the contents of register x.
--                         Especially when using the unnamed register, this is
--                         quicker than "_d{motion}P or "_c{motion}<C-R>"
-- [count]["x]grr        = Replace [count] lines with the contents of register x.
--                         To replace from the cursor position to the end of the
--                         line use ["x]gr$
-- {Visual}["x]gr        = Replace the selection with the contents of register x.