how to delete region with [delete] key in emacs
Asked Answered
M

3

5

I am using Emacs 23.3 on Mac OS X Lion. How can I delete the selected text region with simple key typing—something like delete or C-d? This works on windows without setting anything specific. How can I implement that in Mac OS X Lion?

Minne answered 28/10, 2011 at 1:19 Comment(0)
S
6

Try M-xcua-mode. This will change a lot of things about the way Emacs behaves to fit the behavior of other GUI applications. For more information, see M-S-:(info "(emacs) CUA Bindings").

You can turn it on persistently with M-xcustomize-optionRETcua-mode.

Stelly answered 28/10, 2011 at 2:49 Comment(0)
B
12

You need to enable delete-selection-mode and then it will work ;-)

Barm answered 28/10, 2011 at 6:43 Comment(0)
S
6

Try M-xcua-mode. This will change a lot of things about the way Emacs behaves to fit the behavior of other GUI applications. For more information, see M-S-:(info "(emacs) CUA Bindings").

You can turn it on persistently with M-xcustomize-optionRETcua-mode.

Stelly answered 28/10, 2011 at 2:49 Comment(0)
F
5

If you mean "delete between the mark and the cursor," the normal keybinding for this in Emacs is C-w (Hold down control and press w).

To set the mark, use C-SPC (hold down control and press SPACE).

Selecting a text region and then deleting it is not very common to normal Emacs users. More frequently they use

  • C-k to delete entire lines at a time (or to the end of the current line)
  • M-z (press Esc then z) to "zap to char" which will delete all text to the next occurrence of any character
  • M-DEL (press Esc then DEL) to delete backwards a whole word at a time

and others.

Funereal answered 28/10, 2011 at 1:49 Comment(3)
thanks for you answer. but i want to bind [delete] key todo "delete-char" or "kill-region" in automatic.Minne
i found the way to implements this function. <pre> (defun my-backward-delete-fun() "backward delete a char or delete selected region automic" (interactive) (if (and transient-mark-mode mark-active) (call-interactively 'kill-region) (call-interactively 'backward-delete-char-untabify) ) ) (global-set-key [backspace] 'my-backward-delete-fun) </pre>Minne
answer your own question, so you can help the next person who comes along!Funereal

© 2022 - 2024 — McMap. All rights reserved.