Editing Parentheses in Emacs
Before switching to Emacs, I had been using Vim.
As I do in Emacs, I used to add a bunch of plugins to my
One Vim plugin I miss in Emacs is surround. As the name implies, it is a plugin for editing parentheses and brackets. I knew there existed Emacs packages for that purpose, but I did not think about how I want to do it until recently.
After doing some research and trying out packages, I ended up with the following plan for editing parentheses1:
- To enclose an active region with a pair of parentheses, you can simply type
(in most modes. This is supported by
- To add/delete/change brackets around the point, you can use embrace.
embrace-commander, but I often forget using this command.
- To edit contents inside the surrounding quotes/brackets, you can use
sp-change-enclosingfrom smartparens. I bind
C-c eto this command2.
You can also use expand-region for killing text inside/with a bracket pair.
Other options include isolate and siege-mode. I didn’t choose those packages because the configuration described above would work for most cases.
Note that this is not about editing lisp code in Emacs. I use lispy for that purpose.
This workflow is still not as consistent as in
I must admit that vim can be more efficient than Emacs in some situations for text editing, but I am using Emacs mostly because I need an application that is capable of everything.
I want to know if there is a more elegant way to editing parentheses.