Emacs: delete whitespaces or a word

后端 未结 4 2006
故里飘歌
故里飘歌 2020-12-01 17:21

How can I configure emacs to work in the same way as other modern editors where pressing Alt+D or Alt+Backspace deletes either ad

4条回答
  •  遥遥无期
    2020-12-01 17:38

    If you are using a CC-Mode based buffer, you are probably looking for the Hungry Delete Mode minor mode.

    Try C-c DEL and C-c DELETE in several places to get a feel for the difference.

    If you like the way it works, you can toggle hungry deletion to work for the standard keys by doing M-x c-toggle-hungry-state or just rebind the hungry deletion functions to your preferred binding.

    If you still think you need to piggyback one key to do forward kill word or whitespace, then you can do something similar to c-hungry-delete-forward, or just temporarily rebind c-delete-function and call it.

    (defun c-hungry-delete-forward-word ()
      "Delete the following word or all following whitespace
    up to the next non-whitespace character.
    See also \\[c-hungry-delete-backwards]."
      (interactive)
      (let ((c-delete-function (function kill-word)))
        (c-hungry-delete-forward)))
    

    Check out the Info page (ccmode) Hungry WS Deletion for more.

提交回复
热议问题