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.
+1
A:
Press C-Space (set-mark-command) just before C-w to set the mark at the cursor position so that there is no text between the mark and cursor position to kill.
Steven
2009-08-12 21:04:55
So before accidentally pressing C-w, one should accidentally press C-space?
Beta
2009-08-12 22:30:30
+5
A:
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.
Harold L
2009-08-12 21:28:59
+8
A:
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)
scottfrazer
2009-08-12 21:43:54
+5
A:
Set the variable mark-even-if-inactive
to nil
. That way, you can only kill text if it's actually highlighted.
legoscia
2009-08-13 17:46:02