Plugin
This becomes even easier by selecting the lines, and then searching for the visual selection, and you don't clobber a register through this. There are several plugins that extend the built-in normal mode *
command to visual mode, also my SearchHighlighting plugin. (The plugin page has links to alternative plugins.)
Manually
If you want to do this manually, through a register, use a very nomagic (\V
) pattern, and escape the special characters. To insert the (escaped) register contents into the command-line, insert register <C-R>
with the expression register is used:
/\V<C-R>=substitute(escape(@@, '/\'), '\n', '\\n', 'g')<CR><CR>