From 51fa945a87e8dd6849a6ff635a6598627e0ab455 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Sat, 13 Sep 2025 21:47:49 +0200 Subject: [PATCH] fix(mappings): return to previous cursor position after rename --- lua/ow/core/mappings.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/ow/core/mappings.lua b/lua/ow/core/mappings.lua index d047093..d3b57fa 100644 --- a/lua/ow/core/mappings.lua +++ b/lua/ow/core/mappings.lua @@ -106,7 +106,9 @@ vim.keymap.set("n", "r", function() local word = vim.fn.expand("") local replacement = vim.fn.input('Replace "' .. word .. '" by? ') if replacement ~= "" then + local cursor_pos = vim.api.nvim_win_get_cursor(0) vim.cmd(":%s/\\<" .. word .. "\\>/" .. replacement .. "/g") + vim.api.nvim_win_set_cursor(0, cursor_pos) end end)