LoginSignup
5
6

More than 5 years have passed since last update.

C-w を少し賢くする

Last updated at Posted at 2012-04-19

C-w に少し空気を読んでもらうようにする。(transient-mark-mode 使ってるの前提)

  • region がアクティブじゃない時 は、CLI の C-w と同じく、カーソル左の一単語を削除
  • region がアクティブの時は、通常の C-w
  • transient-mark-mode が無効の時も、通常の C-w
(defun backward-kill-word-or-kill-region ()
  (interactive)
  (if (or (not transient-mark-mode) (region-active-p))
      (kill-region (region-beginning) (region-end))
    (backward-kill-word 1)))
(global-set-key "\C-w" 'backward-kill-word-or-kill-region)

こうでもしないと、region がアクティブじゃない時に Emacs 標準のマークセットで kill-region 発動して「うわあああああ」ってなる。

5
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
5
6