summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <thomas.voss@humanwave.nl> 2024-06-12 10:25:20 +0200
committerThomas Voss <thomas.voss@humanwave.nl> 2024-06-12 18:49:53 +0200
commitcdbfcc8044db6789676ec9a2f8901814a6eecbcf (patch)
tree769e3947d51c3f51aecbe4a851360aa5bb95a2f9
parentbd337833342ca7ac4a35a416806bcd34d82ed045 (diff)
nvim: Make gJ great again
-rw-r--r--.config/nvim/init.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index a11639f..d2c45e5 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -82,6 +82,16 @@ vim.keymap.set('n', '<leader>T', function() vim.cmd.normal('"zX"zp') end,
{ desc = '[T]ranspose the current and previous characters' })
vim.keymap.set('n', '-', ':Ex<CR>',
{ desc = 'Open Netrw' })
+vim.keymap.set('n', 'gJ', function()
+ vim.cmd [[
+ let save = winsaveview()
+ normal! gJ
+ if matchstr(getline('.'), '\%' . col('.') . 'c.') =~ '\s'
+ normal! "_dw
+ endif
+ call winrestview(save)
+ ]]
+end, { desc = '[J]oin lines without whitespace' })
vim.keymap.set('n', '<leader>k', function()
vim.cmd 'vsplit'