diff --git a/plugin/scalpel.lua b/plugin/scalpel.lua index bc6c7c3..ab9c2bf 100644 --- a/plugin/scalpel.lua +++ b/plugin/scalpel.lua @@ -4,8 +4,16 @@ local function substitute_current_word() local word = vim.fn.expand('') - local pattern = ':%s/\\v(' .. word .. ')' - vim.api.nvim_feedkeys(pattern, 'n', true) + local pattern = ':,$s/\\v(' .. word .. ")//gc|:undojoin|1,''-&&" + + local cursor_move = vim.api.nvim_replace_termcodes( + '', + true, + false, + true + ) + + vim.api.nvim_feedkeys(pattern .. cursor_move, 'n', true) end vim.keymap.set('n', 'e', substitute_current_word, { desc = 'Substite current word in file' })