Next: , Previous: Highlighting a region, Up: Common requests

5.10 How can I replace highlighted text with what I type?

Use delete-selection-mode, which you can start automatically by placing the following Lisp form in your .emacs file:

     (delete-selection-mode 1)

According to the documentation string for delete-selection-mode (which you can read using M-x describe-function <RET> delete-selection-mode <RET>):

When Delete Selection mode is enabled, Transient Mark mode is also enabled and typed text replaces the selection if the selection is active. Otherwise, typed text is just inserted at point regardless of any selection.

This mode also allows you to delete (not kill) the highlighted region by pressing <DEL>.