I use the following plugin to search for visually selected text:
" Save register content and type.
let old_reg = getreg('"')
let old_regmode = getregtype('"')
" Calling this function has ended visual mode, so it must be started
" again before the selection can be yanked into the unnamed register.
One possible solution is to use what I call register recall: on the :-command line, Ctrl-r followed by any of the registers (the named ones, like a or 3, or the others, such as - or ") will insert the contents of said register.
(This works in insert mode as well.)
So you could
Yank the text
Substitute with :%s/<C-r>"/replacement/g
It’s also ...
It seems you are using this mapping line-wise by selecting lines with V before executing <leader>e. This is worth a command in my opinion.
command! -range=% -nargs=1 -complete=file MoveTo
\ <line1>,<line2>write! >> <args> | <line1>,<line2>d_
-range=% to allow a range, if none, consider the whole buffer
Pasting over a visual selection should work exactly once. When pasting a second time the visual selection from the first time will be pasted instead of the yanked text. (At least that's what happens in version 8.1.1779, but ISTR that in earlier versions pasting did not work; just like you describe. This might have been changed with 8.0.140, but I can't check ...
The ^@ you're referring to is actually a newline character, so the problem you describe will happen when your visual selection includes the newline (e.g. v$ to select until the end of the line) or when it spawns multiple lines.
Assuming your external tool you're shelling out to is able to handle multiline strings appropriately, Vim's shellescape() will be ...
My preferred solution is
Select your paragraph vip
Hit : and then <C-f> OR press q:
Move up to your :g command and do I'<,'>, then Esc, then <CR>.
As mentioned in the comments, it might be handy to map this:
xnoremap <Leader>. q:<UP>I'<,'><Esc>$
first of all, you can't do it in general for any visual selection, since the ex commands operate on lines, so only for the whole lines which are fully or partially visually selected you can run such a command. E.g. you have a line 'Hello world' with the 'or' selected, but you can't operate on the selection, which is 'or', only on the whole line 'Hello world'