I want to rewrite yank text as follows. Is there any way to do this?
kill the ring:
text-i-want-to-paste
Before:
abcdefghijklmnopqrstuvwxyz ^ corsor
After:
text-i-want-to-pasteuvwxyz
Thanks.
Enable delete-selection-mode . Then select the text to replace. Then press Cy . With delete-selection-mode enabled, you simply type in text that replaces the selected text, as is usually the case outside Emacs. And Cy also replaces it.
delete-selection-mode
Cy
You can also use defadvice. Then this will only work when rewritable mode is enabled:
(defadvice yank (before yank-if-overwrite) (if (bound-and-true-p overwrite-mode) (delete-char (length (current-kill 0)))) ) (ad-activate 'yank)
Here:
(defun crazy-yank () (interactive) (delete-char (length (current-kill 0))) (yank)) (global-set-key (kbd "CMy") 'crazy-yank)