-
-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Labels
wontfixThis will not be worked onThis will not be worked on
Description
I tried adding the following code to my after/ftplugin/spectre_panel.lua to escape special characters when I paste:
vim.keymap.set("n", "p", function()
local text = vim.fn.getreg() -- uses v:register by default
text = string.gsub(text, [[%\]], [[\\]])
text = string.gsub(text, "%.", [[\.]])
text = string.gsub(text, "%(", [[\(]])
text = string.gsub(text, "%)", [[\)]])
text = string.gsub(text, "%[", [[\[]])
text = string.gsub(text, "%]", [[\[]])
text = string.gsub(text, [[%|]], [[\|]])
vim.api.nvim_paste(text, true, -1)
end)The idea is that if I yank "foo.py" and paste it into the spectre panel, it should paste "foo.py" so that it looks for the exact string instead of the regex.
However, the keymap conflicted with
n p *@p<Cmd>lua require('spectre').on_search_change()<CR>
so it didn't work.
Would it be possible to integrate escaping special characters into the plugin itself? Or is there another way to achieve what I'm trying to do?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
wontfixThis will not be worked onThis will not be worked on