Currently I have the following mapping in my vimrc
nnoremap d "_d
nnoremap D "_D
nnoremap C "_C
nnoremap c "_c
nnoremap <leader>d "*d
nnoremap <leader>D "*D"
The result of the above mapping is that everything that is yanked after deleting or changing goes to the black hole register.
Now the last problem I am having is after I paste onto a visual line, the replaced text gets yanked on to the clipboard (default) register. So I tried to use this function which attempts to solve this problem
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
vmap <silent> <expr> p <sid>Repl()
This does not seem to work and I am not sure why. Any help on this issue would be appreciated. Could this have to do with my custom mappings that I defined above?