I want to overwrite text by yank as following. Is there any way to do this?
kill-ring:
text-i-want-to-paste
Before:
abcdefghijklmnopqrstuvwxyz
^
corsor
After:
text-i-want-to-pasteuvwxyz
Turn on delete-selection-mode
. Then select the text to replace. Then hit C-y
. With delete-selection-mode
enabled, you just type to replace selected text, as is usual outside Emacs. And C-y
also replaces it.
Here:
(defun crazy-yank ()
(interactive)
(delete-char (length (current-kill 0)))
(yank))
(global-set-key (kbd "C-M-y") 'crazy-yank)