dd puts the text I want to yank, in some register. Before a yank, a couple more dd's, now the first dd register has changed. How do I yank so that it's the first dd I want. I can't keep track of registers in between.

  • 4
    Choose a named register to yank into, then paste from that. For example "ayy then delete something, move, and press "ap.
    – Heptite
    Mar 2 at 1:21
  • 3
    The last yanked text is accessible from the "0 register (see :help "0). So, instead of p, use "0p.
    – husB
    Mar 2 at 6:31
  • 1
    That's strange. Deleted lines of text should go to the "1 register, not "0. Anyway, if "0 does not work for you, I recommend either (1) deleting to null register, as in yy, "_d, p, or (2) yanking to a specific register, as per Heptite's comment.
    – husB
    Mar 2 at 7:41
  • 2
    Oh, are you using any yank-related plugins by any chance? if so, it would be good to add that to your question
    – husB
    Mar 2 at 8:21
  • 1
    I mean paste when I say 'yank', like in emacs.
    – eguneys
    Mar 19 at 23:04

1 Answer 1


Allow me to rephrase your question. This is to make sure that I understand it fully:

  1. You press dd to cut some text that you want to paste at a later point in time.

  2. You see another line that you wish to remove, and press dd to remove it. You may need to do this for multiple lines.

  3. Now, you wish to use p to paste the text content in step 1.
    However, the content in step 2 is pasted.

The solution is to use registers. These are triggered with the " key. (If it is difficult to press, we can use a mapping.)

The problem is that dd actually does a "cut", instead of "removing" text. That is, in step 2, dd actually stores the text, instead of removing it.

We can resolve this is two ways, choose one or the other:

  • First, in step 2, use "_dd to actually remove the text (cut to null register, or cut to nowhere). This method is preferred if there are few lines to remove.

  • Otherwise, in step 1, save the text to some register (e.g., "rdd) and paste that register in step 3
    (e.g., "rp). This method is preferred if there are many lines to remove in step 2.

We have to make a change either in step 1, or in step 2. This is because we cannot use the same mapping dd to both "cut" and "remove" text.

If " is too hard to press, we can use a mapping. For example, we can use

nnoremap - "

to replace the " key with -. Then, using the second solution, we can do

  1. -rdd
  2. dd
  3. -rp

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.