LoginSignup
6
6

More than 5 years have passed since last update.

delete-word的なコマンドがなかったので作った

Last updated at Posted at 2015-08-17

Emacsにはデフォルトでkill-word(M-dにバインド)やbackward-kill-word(M-backspaceにバインド)がある。削除系コマンドとして確かに便利なのだが、削除したものをkill-ringにどんどん放りこむのがイヤだと思ったので、純粋に削除のみを実行するコマンドを書いたということ。

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

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

適当なキーバインドに設定して中々便利に使っている。例えば私は以下のように設定している。

(global-set-key (kbd "C-M-<backspace>") 'backward-delete-word)

車輪の再発明感は高い。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6