Hmm. Maybe a strategy more like this would work:
vnoremap <expr> p
\ '<Esc>:let g:old_unnamed_reg=getreg()<CR>'
\ . ':let g:old_unnamed_type=getregtype()<CR>'
\ . 'gv'.(v:register!='"' ? '"'.v:register : '').'p'
\ . ':call setreg(''"'',g:old_unnamed_reg,g:old_unnamed_type)<CR>'
Hmm. I've been using visual mode p a bit, and realised this strategy
doesn't really work either.
The unnamed register always points to another register. We don't know
what it's pointing to before the operation, and setting it afterwards
always sets "0 and sets the unnamed register to point to that. However,
the operation, in setting "" actually sets "1 or "- (and makes "" point
to it).
So to make this work, we'd need some new feature implemented in Vim
itself, I think.
Maybe take a step back, though: Why did you want this? Maybe there is
some other workaround that can achieve what you want a different, but
convenient, way.
The downside is that the replaced text doesn't get kept anywhere.
I was wrong about that. The replaced text will be in "1 or "- as well as
"".
It's the previous contents of "0 that is lost, if "" didn't happen to
point to it before.
Ben.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php