multiple-cursors.nvim icon indicating copy to clipboard operation
multiple-cursors.nvim copied to clipboard

Normal mode not match the whole word.

Open milkpuff opened this issue 4 months ago • 0 comments

图片 In normal mode, I put cursor at 'is', and then match next to 'this', and then match next to 'this' In this case, my intention is to match the whole word 'is', not 'is' in 'this'. Normal mode match next should match the whole word. Visual mode should match the selected. SublimeText and VSCode 'ctrl+d' runs like this logic.

To fix this is simple. Just add one line to function get_search_pattern() to match the whole word in normal mode.

--- a/lua/multiple-cursors/init.lua
+++ b/lua/multiple-cursors/init.lua
@@ -600,6 +600,7 @@ local function get_search_pattern()
     pattern = get_visual_area_text()
   else -- Normal mode
     pattern = vim.fn.expand("<cword>")
+    pattern = "\\<" .. vim.pesc(pattern) .. "\\>"
   end
 
   if pattern == "" then

milkpuff avatar Oct 12 '24 14:10 milkpuff