diff --git a/lua/lazyvim/plugins/extras/editor/inc-rename.lua b/lua/lazyvim/plugins/extras/editor/inc-rename.lua index a7c65243..d538d4fb 100644 --- a/lua/lazyvim/plugins/extras/editor/inc-rename.lua +++ b/lua/lazyvim/plugins/extras/editor/inc-rename.lua @@ -1,3 +1,18 @@ +-- enhances the 'IncRename' command cleaning +-- retaining only 'IncRename ' if the command starts with it and has additional characters. +local function enhance_rename_cleaner() + local cmd_line = vim.fn.getcmdline() + local prefix = "IncRename " + local prefix_length = #prefix + + if cmd_line:sub(1, prefix_length) == prefix and #cmd_line > prefix_length then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("" .. prefix, true, true, true), "n") + else + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("", true, true, true), "n") + end +end + +vim.keymap.set("c", "", enhance_rename_cleaner, { noremap = true, silent = false }) return { -- Rename with cmdpreview