How to replace a region in emacs with yank buffer contents?

后端 未结 7 2059
一向
一向 2020-12-24 05:26

When I use VIM or most modeless editors (Eclipse, NetBeans etc.) I frequently do the following. If I have similar text blocks and I need to change them all, I will change on

7条回答
  •  一向
    一向 (楼主)
    2020-12-24 06:08

    For anyone landing on this who doesn't want to change the global setting like me, I use this function and key binding:

    (defun replace-yank(beg end)
      (interactive "r")
      (kill-region beg end)
      (yank 3))
    
    (global-set-key (kbd "C-S-y") 'replace-yank)
    

    I intentionally add the selected text to the kill ring incase I want it later, and yank what was previously first in the ring.

提交回复
热议问题