:help v_p
:help registers
and I cannot find this behavior documented, and so I wonder if it's a bug.
If I visually select a block and hit "p" to paste from the unnamed
buffer, the block I'm overwriting gets put into the unnamed buffer.
There are two strange consequences of this:
1. If I need to make several replacements down my file, I have to do a
new copy between each replacement (or use a new buffer).
2. If I select the same block over and over again, hitting "p" will
toggle the block back and forth from its old state to its new state.
Is this the desired behavior? If so, shouldn't it be documented?
Also, is there any way to disable this behavior? I'm happier knowing
that only "d", "c", "s", 'x", and "y" put things into the unnamed buffer.
Thanks --
Ted
--
Ted Pavlic <t...@tedpavlic.com>
Please visit my ALS association page:
http://web.alsa.org/goto/tedpavlic
My family appreciates your support in the fight to defeat ALS.
"Ben Fritz" <fritzo...@gmail.com> wrote :
> > Also, is there any way to disable this behavior? I'm happier
> > knowing that only "d", "c", "s", 'x", and "y" put things into the
> > unnamed buffer.
>
> :vnoremap p "_d"0P or similar ought to do it.
In order to avoid overwriting the @" register, but still being able to
paste the content of any register, I came up with this [1]
"------------------------------------------------------------------------
" I haven't found how to hide this function (yet)
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
" This supports "rp that permits to replace the visual selection with
" the contents of @r
vnoremap <silent> <expr> p <sid>Repl()
"------------------------------------------------------------------------
[1] This dozen lines is maintained there:
http://code.google.com/p/lh-vim/source/browse/misc/trunk/macros/repl-visual-no-reg-overwrite.vim
--
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/
It's not so much a bug...the help on "v_p" mentions
"Implementation detail: it actually works by first putting the
register after the selection and then deleting the selection."
The deletion is what's throwing you because it goes to the
unnamed register. You might try something like one of the
following:
:vnoremap <f4> "_c<c-r>"
:vnoremap <f4> <esc>Pgv"_d
which will do the deletion to the black-hole register. The only
catch is that you can't paste from a named register with these
mappings.
-tim
> I've looked in:
>
> :help v_p
> :help registers
>
> and I cannot find this behavior documented, and so I wonder if it's a bug.
>
> If I visually select a block and hit "p" to paste from the unnamed
> buffer, the block I'm overwriting gets put into the unnamed buffer.
> There are two strange consequences of this:
>
> 1. If I need to make several replacements down my file, I have to do a
> new copy between each replacement (or use a new buffer).
>
> 2. If I select the same block over and over again, hitting "p" will
> toggle the block back and forth from its old state to its new state.
>
> Is this the desired behavior? If so, shouldn't it be documented?
>
> Also, is there any way to disable this behavior? I'm happier knowing
> that only "d", "c", "s", 'x", and "y" put things into the unnamed buffer.
No, it cannot be disabled. Deleted text always has to go somewhere.
I agree that this isn't easy to understand. Let me add this text to the
help:
The previously selected text is put in the unnamed register. If
you want to put the same text into a Visual selection several
times you need to use another register. E.g., yank the text to
copy, Visually select the text to replace and use "0p . You can
repeat this as many times as you like, the unnamed register will
be changed each time.
--
hundred-and-one symptoms of being an internet addict:
128. You can access the Net -- via your portable and cellular phone.
/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
That passage is clear to me. (I assume it's an addition to ":help v_p"?)
I see -- that makes sense. The downside of that particular remap is that
sometimes I might want to paste out of another buffer. But "0p is better
than having to do a p and then finding the text to copy again.
>> 2. If I select the same block over and over again, hitting "p" will
>> toggle the block back and forth from its old state to its new state.
> That's actually kind of cool...and lets you move blocks around easier.
At first, I suppose the "swap" character of the whole thing seems neat,
but I have a feeling it's not really useful in practice.
Still, I'm persuaded by the argument that deleted stuff (especially big
blocks) have to be put somewhere.
> :vnoremap p "_d"0P or similar ought to do it.
Again, it would be nice if there was a remap that would still allow for
pasting out of other buffers...
Thanks! --