Endless Parentheses

Ramblings on productivity and technical subjects.

profile for Malabarba on Stack Exchange

Where do YOU bind expand-region?

Expand region is one of those packages that deserves to be built-in. It's so simple and useful it makes Emacs worthwhile all by itself. Fundamentally, the entire package boils down to a single command, expand-region, which incrementally increases the selected region by semantic units. So deciding where to bind this command is an important decision.

The Readme suggests C-= and I've seen recurring recommendations for S-SPC, which I used for a while, but neither felt quite right for me. After marking a small region, the most common operation for me is to copy it, but it's very awkward for my fingers to hit S-SPC M-w. With that in mind, in one of my brightest epiphanies, I defined the following keybind.

(global-set-key (kbd "M-2") #'er/expand-region)

Not only does M-2 use the same modifier as M-w, but it's right above the latter. I couldn't hope for a better key. Besides, after years of switching tabs in Firefox, my fingers are sniper rifles when it comes to hitting M-2, making this combo extra speedy. The downside is that you forgo using Meta for prefix arguments, but I'm fine with that.

When I select large regions, I'm probably killing instead of copying. While M-2 C-w is not terribly natural, it's also not awkward, so the key is good enough here. Finally, M-2 also fits well with my multiple-cursors keybinds, but that's a topic for another post.

comments powered by Disqus