I haven't found some elegant way to do so bu you can create your own way to do so.
Code
- First you can create somme key bindings (work on visual mode only).
xnoremap <Leader>y y:MultiRegister<Space>
xnoremap <Leader>d d:MultiRegister<Space>
xnoremap <Leader>c c:MultiRegister<Space>
xnoremap <Leader>x x:MultiRegister<Space>
xnoremap <Leader>s s:MultiRegister
- Secondly you can create your own custom command that will take the register name you gave:
command -nargs=+ MultiRegister call CopyToSelectedRegisters('<args>')
- Finally you create a function that copy the selected area to the rest of the given registers:
function CopyToSelectedRegisters(SelectedRegisters)
"Split the given registers by space
let tab= split(a:SelectedRegisters)
"for each register
for register in tab
echo "let @".register."= @\""
"Copy the content of the default register
execute "let @".register."= @\""
endfor
endfunction
Usage
- In visual mode, select the area you want and press
<leader>
followed by y (or d,c,x,s).
- You will be prompted in the command mode (bellow) with the MultiRegister command followed by a white space.
- Enter the registers you want (for instance
a b c +
) and press enter.
- Vim will do the copy to the designated registers (you can check it with :reg).
I hope this will help you
"ax"+x
would work, since eachx
would delete a different character of the buffer, no? You can set a register explicitly with:let @+ = @a
(better is:call setreg(...)
) and there's a TextYankPost event you can use where you could use to mirror named registers to the clipboard perhaps?Y
instead ofx
but switched because I thought it was simpler, without realising that wouldn't work. I'll change ita
by default, if I don't specify a register, and if I do, then go toa
and whichever I specified.a
and whichever I specified." Yeah, but why? I still don't get it... The register rules are quite complex, but in a way something like this already happens (with deletes, in specific line/multi-line deletes.) For example,"zdd
goes to both"z
and to numbered register"1
(and other numbered registers beyond 0 are shifted down one.)