In insert mode, Ctrlr/ (see :h "/) will paste the contents of the search register. However, if you search for a word with * and paste the search register, it will put in the special word boundary characters \< and \>. Or, if you’re lucky, you might get ‘\Vsearch. I think this is silly, but I’m sure VIM has its reasons for making my life harder. How would I go about getting the contents of the search register without special vim magic characters?
In insert mode, Ctrl r / (see :h / ) will paste the contents
Share
The search register may contain no (simple
/foosearch), few (\<cword\>search from * command), or a lot (^\%(foo\|bar\)\w\+!\?) “special characters”. For the first two, there’s usually a single match, for the last, there can be many matches.Initially I’ve used a mapping that filtered away the special regexp atoms, but then I’ve written a more general PatternComplete plugin (just published), that provides insert-mode and command-line mappings to insert the match(es). It also allows you to enter a regexp and then insert all matches.