7

I love vim, but one of my problems with it is that whenever I use x or d to remove text, it copies the deleted text into the buffer/clipboard.

More specifically, it's a problem when I have some text copied, and then I need to delete a second block of text before pasting the first text.

Is there a command that deletes text but does not copy it? If not, is there a custom command for this?

Thanks!

Kyle Challis
  • 981
  • 2
  • 12
  • 28
  • 1
    there might be, but why would you want this? i find it very convenient that deleted items are moved to the buffer (i've hit ddp countless times in my life) – acushner Mar 12 '14 at 20:37
  • 1
    @acushner there is a few times where I would copy something and go to where I want to paste it and there is something in the way that needs to be deleted. I do understand that you can highlight what you want deleted and paste over it but what if there were a few things not together that need to be deleted? you'll have to paste first anywhere whats on the clip board, and then delete each piece of what you want then copy again to paste. – 13ruce1337 Mar 12 '14 at 20:40
  • @acushner I agree that it can be nice, but `u` (undo) serves that purpose if you deleted on accident, or `yyp` for copying and pasting. Specifically, it's annoying when I have some text copied, and then I need to delete a different block of text before pasting the first text. Thanks for the question, I will clarify my question : ) – Kyle Challis Mar 12 '14 at 20:43
  • @13ruce1337 exactly. You beat me to it! : ) – Kyle Challis Mar 12 '14 at 20:44
  • possible duplicate of [Any way to delete in vim without overwriting your last yank?](http://stackoverflow.com/questions/3638542/any-way-to-delete-in-vim-without-overwriting-your-last-yank) – user Mar 12 '14 at 20:45
  • good points, but in those situations i always just put it down over the contiguous area i want to replace via visual mode. it's irrelevant if there are multiple non-contiguous areas because it reduces to paste over first one, delete 2nd one (all the way to nth one...) – acushner Mar 12 '14 at 21:00

2 Answers2

12

Use black hole register

"_d

Setup your own mapping in vimrc like ,d to save some typing

usha
  • 28,973
  • 5
  • 72
  • 93
5

There are more ways than one to solve the problem. One has already been suggested by Vimsha.

Another way to solve the problem is to copy your important text to a named register. Say you wanted to 5 lines of text to be deleted from one place and copied in a different place.

"a5dd will delete 5 lines of text and save them in the a register.

Do various other operations.

Now move to the location where you want to copy them.

"ap or "aP will copy the 5 lines of text from the a register to the current location.

R Sahu
  • 204,454
  • 14
  • 159
  • 270