summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/nvim/lua/custom/config/keymaps.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/.config/nvim/lua/custom/config/keymaps.lua b/.config/nvim/lua/custom/config/keymaps.lua
index 5d983a7..74b2e37 100644
--- a/.config/nvim/lua/custom/config/keymaps.lua
+++ b/.config/nvim/lua/custom/config/keymaps.lua
@@ -31,7 +31,13 @@ local function yank_filepath_to_clipboard(os)
end
end
+function RemoveClipboardCR()
+ local clipboard = vim.fn.getreg('+'):gsub('\r', '')
+ vim.fn.setreg('+', clipboard)
+end
+
local function paste()
+ RemoveClipboardCR()
local value = vim.fn.getreg('+')
if vim.fn.mode() == 'c' then
-- value = vim.split(value, '\n')[1] -- only use first line (default with normal pasting)
@@ -42,10 +48,14 @@ local function paste()
end
end
+
-- "Greatest Keymap ever" - ThePrimeagen
-- https://www.youtube.com/watch?v=qZO9A5F6BZs&list=PLm323Lc7iSW_wuxqmKx_xxNtJC_hJbQ7R&index=4
set('x', '<leader>p', '"_dP')
+set('n', 'p', '<cmd>lua RemoveClipboardCR()<cr>p', { noremap = true })
+set('n', 'P', '<cmd>lua RemoveClipboardCR()<cr>P', { noremap = true })
+
-- Misc
set({ 'n', 'i' }, '<C-a>', '<Esc>ggVG', { desc = 'Visually Highlight [A]ll' })
set('i', '<C-H>', '<C-w>', { desc = 'Ctrl + Backspace to delete word' })