Emacs: how to delete text without kill ring?

后端 未结 15 1077
旧巷少年郎
旧巷少年郎 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:55

    Technically, the other answers are wrong on the first part.

    Here is my implementation and motivation:

    (defun delete-word (arg)
      "Delete characters backward until encountering the beginning of a word.
    With argument ARG, do this that many times."
      (interactive "p")
      (delete-region (point) (progn (backward-word arg) (point))))
    

    I adapted the code here from "kill-word" in simple.el. I switched kill-region with delete-region and forward-word for backward-word. This way it TRUELY does not affect the kill-ring, unlike the other situations where, outside of emacs, I noticed that the kill-ring was influenced.

提交回复
热议问题