I often find it is needed to add / remove parenthesis / bracket around a marked region in Emacs.
Currently I do the adding manually by:
And the removal in the other way around.
However, this seems cumbersome and error prone because of the movement of cursor. From a safety point of view, if I delete parenthesis in pairs, I feel safer, because it is an atomic operation
Is there a built-in or hand-crafted function in Emacs to do it with respect to marked region?
Removing a pair of surrounding characters (parens, brackets, whatever) with the delete-pair
function:
You don't have to mark the region.
M-x delete-pair
C-M-u
for backing out of the pair and then M-x delete-pair
.M--
(negative argument) and then M-x delete-pair
Enclosing a region with parens:
M-(
.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