5

I don't know if its a retarded problem but it's a funny dilemma. When I want to delete text that I want to place somewhere else, but that place has other bunch of text that I don't want, I would delete that text, but in the process I copy a new clipboard so the previously deleted text disappear.

Any suggestions to solve this?

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
alexchenco
  • 50,467
  • 73
  • 227
  • 400

5 Answers5

9

A few possible solutions:

Delete the undesired text first :)

or

When deleting the desired text store it in a register other than the default register e.g. to delete the desired text to the end of the current line and store it in register b:

"bd$

Then delete your undesired text.

Then paste the contents of register b:

"bp

or

Delete the undesired text to the black hole register as suggested in the answer linked to by Yarek T using:

"_d
Community
  • 1
  • 1
mikej
  • 63,686
  • 16
  • 149
  • 130
6

maybe this question might shed some light onto your problem. 54255

It uses the "black hole buffer" to delete lines without adding them to the yank buffer.

Community
  • 1
  • 1
Yarek T
  • 9,435
  • 2
  • 27
  • 37
2

Another solution is to use the number registers. When you delete a chunk of text it is moved into register 1, the current contents of register 1 is moved into register 2, etc. The contents of register 9 are discarded. However this only works for changes longer than a line, so small deletes are not captured.

So you can delete the first region, delete the second region, then paste from register 2.

Personally I prefer to use registers a-z, but the numbered registers are useful if you delete some text and then realise you forgot to specify a register.

Do :help "1 for more information.

You can also see what is currently in all the registers, including 1-9, with :registers

Dave Kirby
  • 24,472
  • 5
  • 64
  • 80
2

Type:

:registers

And you'll get a list of registers that contain all previous deletions. You can always pick one to paste. E.g. for registers:

"1   Item1^J
"2   Item3^J
"3   Item2^J

pick the second one and paste it with:

"2p
Aleksa
  • 89
  • 3
0

Try the yankring plugin.

tfmoraes
  • 706
  • 1
  • 8
  • 18