2

When I copy something first and then want to paste after I delete something, if I delete with CTRL+Backspace it pastes what I deleted when I CTRL+V (I can copy with CTRL+C and paste with CTRL+V in emacs). How can I configure emacs to paste what I copied before?

2 Answers 2

2

As you can paste using C-v, I guess you are using cua-mode. In cua-mode yanking earlier kills using a numeric prefix does not work. However, cycling over earlier kills by pressing M-y (after first pasting using C-v) still works fine.

1

When you delete text with C-<backspace> it is added to the kill-ring in front of the text you copied previously using C-c. You could of course change this behavior by binding something like (delete-region (point) (progn (forward-word -1) (point))) to C-<backspace> instead of backward-kill-word, and similarly for other kill commands... but this is not the Emacs way.

Instead, like dalanicolai points out, the easiest way to paste what you initially copied is to first press C-v to paste (yank) the last kill and then press M-y to rotate through the kill ring (yank-pop) until you're back at the text you want. You can also use M-y directly to select from the kill ring using completion.

Another approach is to enable delete-selection-mode and then just select the text you want to replace, e.g. using C-SPC and M-b, before replacing it using C-v.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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