4

I would like to not have vim copy items to the default register when I delete or change an item; for that, the following configuration seems to do the job perfectly. However I noticed that the only thing that is not working is when I visually select some lines then delete them, those lines get yanked to the default register. Is there any way that those visually selected lines don't get yanked to the default register when I delete them. I would like them to go to the black hole register. This is my current configuration:

nnoremap d "_d
nnoremap D "_D
nnoremap C "_C
nnoremap c "_c

nnoremap <leader>d "*d
nnoremap <leader>D "*D"

"When you paste do not copy what you pasted over.
"This happens when you paste over a visual selection
vnoremap p "_dp
vnoremap P "_dP
  • Pro-tip: the "0 register will always have the last yanked text. See :h quote0 – Peter Rincker Sep 28 '16 at 20:04
7

nnoremap only affects [n]ormal mode and will not affect [v]isual mode. You need vnoremap for that:

vnoremap d "_d
  • 1
    You could also use xnoremap. – DJMcMayhem Sep 28 '16 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.