Expand region

I posted recently about cutting text by word, line and sentence, but by default most of the commands cut from the point to the beginning or end of the word/line/sentence. I previously posted a nice fix for cutting a whole line, but in this post I’ll cover a more general solution.

The package expand region expands the selected region by semantic units i.e. going from word to sentence to paragraph in prose, but also by sensible units for code as well.

If you use my recommended setup, prelude then the command you need is already there – just hit C-– and away you go.

Otherwise, install the package expand-region, and then add the following to your emacs config file

;;expand region
(require 'expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)

I would make an animated gif to illustrate this, but there is a great emacs rocks video by the author of the package. Check out the other videos in that series for more good things.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s