You could make it a one liner using a range:
2,3w >> b | 2,3d
And if you want to keep doing this with visual selection, you can select the lines and then use '< and '> for the range:
'<,'>w >> b | '<,'> d
Edit To address the questions in comments:
If the file you're trying to write doesn't exist you can use w! to force the ...
To modify the content of a register while keeping its type (characterwise, linewise or block) you need to use setreg(). Otherwise Vim is only able to choose the register type as characterwise or linewise. There is note at :help setreg() which hints at this:
Note: you may not reliably restore register value
without using the third argument to getreg() as ...
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 ...
A custom operator that select and paste from any register:
nnoremap ,p :call <sid>opfunc_reg("<sid>select_and_paste")<cr>
" Apply current register to g@ . It's not allowed to set opfunc to s:func, i
" have to use a func argument.
" In function scope of normal map, v:register won't be changed by ex
" command (except :normal) ?
AFAIK, there is no direct way to do that in Vim.
Here is a workaround:
First of all I have the following mapping in my vimrc (From Vim Tips Wiki, Tip 759):
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
With this you can visually select the text you have just pasted (or changed).
Note that gp is already used by Vim for
Just like "...
For some reason, editing _vimrc in the Vim file wasn't working. From within vim, if I used :e! $MYVIMRC to change the file, everything worked out.
I removed set clipboard=unnamedplus and the behavior is now back to normal. Whew!