From cdbfcc8044db6789676ec9a2f8901814a6eecbcf Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 12 Jun 2024 10:25:20 +0200 Subject: nvim: Make gJ great again --- .config/nvim/init.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to '.config') 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', 'T', function() vim.cmd.normal('"zX"zp') end, { desc = '[T]ranspose the current and previous characters' }) vim.keymap.set('n', '-', ':Ex', { 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', 'k', function() vim.cmd 'vsplit' -- cgit v1.2.3