(I feel like there should be duplicate for this, but I could not find it. Pardon me.)


How can I delete word backwards without it being copied to buffer?


I developed a habit of coping text from somewhere, coming to emacs, using M-Backspace to delete some text, and then yank (C-y). Unfortunately, it is bound to backward-kill-word, which "overwrites" whatever I just copied from another place. I am looking for delete-backward-char-like functionality, but for words (like delete-backward-word) and I want it to be bound to M-Backspace. I suspect I just don't use emacs properly or "not thinking the emacs way". Should I change my habit? If so, then how?


2 Answers 2

(defun my-delete-backward-word ()
  (interactive "*")
  (delete-region (point) (mark)))
  • Wow! Thank you! I've been suffering with this for a few years now, but no more. Commented Dec 21, 2017 at 20:09
  • I started using windows 10 and emacs 26.1 and it looks like it stopped working. Commented Dec 12, 2018 at 18:58

As an alternative to the nice solution provided by @AndreasRohler , you could use counsel-yank-pop, from the counsel package, instead of yank here. The workflow would then be:

  1. Copy text from outside emacs
  2. Move to emacs and M-backspace to delete the old text
  3. Paste with M-y, i.e., counsel-yank-pop, and choose the second option (your copied text)

This requires one additional keystroke over @AndreasRohler's solution. However, it preserves the behaviour of M-backspace, and doesn't require a new keybinding for my-delete-backward-word, so that might be a worthwhile tradeoff, depending on how frequently you want to use backward-kill-word vs my-delete-backward-word.

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