I have a highlighting mode (forget what it's called) that shows me, through highlighting the text, what region I have selected between mark and point. this comes in very handy when killing regions. However, sometimes, even when no text is visibly highlighted but i accidentally press C-w it still occasionally kills some text. My question is how do i stop this behaviour? I only want it to kill text IF i've highlighted it.
Define your own function and override the key-binding:
(defun my-kill-region ()
(interactive)
(if (region-active-p)
(call-interactively 'kill-region)
(message "Region not active, didn't kill")))
(global-set-key (kbd "C-w") 'my-kill-region)
M-x transient-mark-mode
will keep the region highlighted even after you start typing, and when you use C-Space to set mark. Then you'll see what C-w will kill.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With