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
Thanks.
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.
You can also use defadvice. Then this will only work when overwrite-mode is on:
(defadvice yank (before yank-if-overwrite)
(if (bound-and-true-p overwrite-mode)
(delete-char (length (current-kill 0))))
)
(ad-activate 'yank)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With