fix(mappings): return to previous cursor position after rename

This commit is contained in:
2025-09-13 21:47:49 +02:00
parent 2efd7bd243
commit 51fa945a87
+2
View File
@@ -106,7 +106,9 @@ vim.keymap.set("n", "<Leader>r", function()
local word = vim.fn.expand("<cword>") local word = vim.fn.expand("<cword>")
local replacement = vim.fn.input('Replace "' .. word .. '" by? ') local replacement = vim.fn.input('Replace "' .. word .. '" by? ')
if replacement ~= "" then if replacement ~= "" then
local cursor_pos = vim.api.nvim_win_get_cursor(0)
vim.cmd(":%s/\\<" .. word .. "\\>/" .. replacement .. "/g") vim.cmd(":%s/\\<" .. word .. "\\>/" .. replacement .. "/g")
vim.api.nvim_win_set_cursor(0, cursor_pos)
end end
end) end)