An auxiliary register is unnecessary; use :exec
in order to evaluate an expression and use the result as an argument to a command. I'm not sure whether strtrans()
is somehow advantageous, but replacing \n
directly seems to work. Either way, make sure to use fnameescape()
. Also, use noremap
in order to avoid recursive mappings unless you need them. If this particular mapping is intended only for visual mode, xnoremap
is even better.
xnoremap <F8> y \| :exec "e" fnameescape(substitute(getreg('"'),'\n','','g'))<CR>