我希望“删除到单词结尾”命令删除单词,无论光标位置如何。
答案 0 :(得分:4)
(defun my-kill-word ()
(interactive)
(backward-word)
(kill-word 1))
(global-set-key (kbd "M-d") 'my-kill-word)
答案 1 :(得分:1)
更好的代码可能是:
(defun my-kill-word ()
(interactive)
(unless (looking-at "\\<")
(backward-word))
(kill-word 1))
(global-set-key (kbd "M-d") 'my-kill-word)
因此,只有当我们不在这个词的开头时,我们才会向后移动 然而。