Linum-mode

This is another note to myself. Recently I was examining the internal structure of the decimal expansion of a number. In order to do this, I put the decimal representation of the number in a buffer and did a query-replace-regexp substituting <digit><space> for each <digit>. Then I set the fill column to 2 and did a refill. That gave me the number with each digit on a single line. I wanted to know the position of each digit. It’s easy to find that out by moving the point to the relevant line and, given that line-number-mode is on, just reading the line number from the mode line. But I wanted to see the positions for all the lines at once.

I knew there was a command to put each line’s number in the left fringe and had even used it but I couldn’t remember what it was. Furthermore, I couldn’t find it in the documentation. I tried things like apropos line and apropos number and other similar constructions but couldn’t find it. Eventually I gave up and started thinking about where I had first seen the command. It seemed to me that it was in an old Emacs-Fu post so I went to DJCB’s blog and did a search on “line number” and the correct post popped right up.

The right answer is linum-mode. The command name is suggestive of its function but it’s still hard to go from the functionality to the command’s name so I am documenting it here. It’s not a command that I use very often so it’s hard to remember its name but when you need it, nothing else will do.

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

3 Responses to Linum-mode

  1. Todd Edwin King says:

    This is a good use case for defalias. linum-mode is one of those “too terse” legacy names that make it difficult to find the feature you need (I would quote Jules Winnfield here about “speaking English”, but I’ll refrain ;)

    For official Emacsen, something more expressive and intuitive is in order – line-numbering-mode perhaps?

    • jcs jcs says:

      This is a good use case for defalias.
      You’re right: an alias is definitely called for here. I always think linum-mode, that makes sense; I should be able to remember that. Of course I never do but something like lnm should work and will, in any event, be in my initl.el.

  2. chad says:

    While I never use the menubar in day-to-day emacsing, it can be helpful for finding things like this.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>