Numbering Lines In A Rectangle

A few days ago, I wrote about how Evan Moses used a bit of Elisp to solve a user interface problem he was having. I liked his solution because it was simple and provided yet another example of how Emacs can adjust itself to the user rather than the other way around. Now he’s back with another example of how Emacs lets us have it our way.

This time, he wanted to number a few consecutive lines. Org mode will do that for you in code blocks, of course, but he needed a more general solution. His first thought was to use a keyboard macro with an auto-incrementing counter but he did a bit of Googling and discovered that, as usual, Emacs has us covered.

It turns out that Emacs has a command just for that. Who knew? Certainly not me. All you need to do is select the rectangle you want to number and call rectangle-number-lines. Take a look Moses’ post for the details.

It’s another example of how someone thought to provide a functionality that we didn’t even know we needed. Sadly, these things are hard to discover but sooner or later someone like Moses comes along and enlightens us.

This entry was posted in General and tagged . Bookmark the permalink.