Saturday 28 September 2024
Update regarding quotes around active region
============================================
This week I wrote a short phlog post about the ease in Emacs of
surrounding an active region with quotes [1].
Today, defanor was so kind to remind me that this is not the default
Emacs behavior. A short test using `emacs -Q' (which starts Emacs
without any user configuration) confirmed this.
Easy surrounding a region
-------------------------
The behavior I described is as follows:
* select text to create a region, f.e., use C-M-SPACE once or
more times to select some words
* type a double quote (")
and Emacs will surround the region with double quotes.
Electric pair
-------------
Emacs in the default config does not work like this. It will just
put a double quote at the position of point. You need to enable
`electric-pair-mode' for this.
Add the following to your Emacs init file, like ~/.emacs:
(electric-pair-mode t)
You can fine tune the working by adding an expression to the
init file, like;
(setq electric-pair-pairs '(
(?\{ . ?\})
(?\( . ?\))
(?\[ . ?\])
(?\" . ?\")
))
To see the documentation of electric-pair-mode, issue
the command `C-h f' followed by `electric-pair-mode',
Have fun!
[1]:
gopher://box.matto.nl/0/til-setting-quotes-around-active-region.txt
Last edited: $Date: 2024/09/28 19:22:04 $