Emacs: how to delete text without kill ring?

后端 未结 15 1078
旧巷少年郎
旧巷少年郎 2020-12-04 14:00

I\'d like to just delete some text so I can yank some other text instead of it. How can I do that? C-w cuts the selected text to kill ring and I end up with

15条回答
  •  天命终不由人
    2020-12-04 14:40

    Here's a version of kill-region that doesn't force values into the kill-ring.

    (defun kill-or-delete-region (beg end prefix)
      "Delete the region, storing it in the kill-ring.
    If a prefix argument is given, don't change the kill-ring."
      (interactive "r\nP")
      (if prefix
          (delete-region beg end)
        (kill-region beg end)))
    
    (global-set-key (kbd "C-w") 'kill-or-delete-region)
    

    This enables you to do C-w as before, but C-u C-w now deletes text without changing the kill-ring.

提交回复
热议问题