diff options
| author | Kyren223 <ulmliad223@gmail.com> | 2024-10-26 15:15:19 +0300 |
|---|---|---|
| committer | Kyren223 <ulmliad223@gmail.com> | 2024-10-26 15:15:19 +0300 |
| commit | 201e113a6503cdf0ec1f431d525e9fbd9eec23fd (patch) | |
| tree | 2c78de96842b9426d91ba65dfe01b9b96a0b3afc /.config/nvim | |
| parent | 0b7b0abf3ebfda3df0fe3f2654b771da1fce919a (diff) | |
Automatically remove \r when pasting in NVIM
Diffstat (limited to '.config/nvim')
| -rw-r--r-- | .config/nvim/lua/custom/config/keymaps.lua | 10 |
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' }) |
