Line number column in Emacs


This is something I’d always wished Emacs did; finally got around to finding a minor mode for it.

While the built-in line-number and column-number modes are fine, linum-mode makes it much easier to see where you are in the code at a glance.

To apply it to all buffers by default, throw the following in your .emacs:

(require 'linum)

Update: Now baked-in to version 23+ of Emacs!

5 thoughts on “Line number column in Emacs

  1. Hi,

    As this worked out for you, can you please help me. I followed the instructions and I am getting this error:
    An error has occurred while loading `/home/kmodi/.emacs’:

    Symbol’s function definition is void: global-linum-mode

    To ensure normal operation, you should investigate the cause
    of the error in your initialization file and remove it. Start
    Emacs with the `–debug-init’ option to view a complete error

  2. Thanks, your advice works by adding (global-linum-mode) in my ~/.emacs file.

    I was just surprised that the global-linum-mode hadn’t been available till v.23!
    The line number column is a must for me…

    Linux (Xubuntu 9.04), Emacs 23

  3. No problem.

    BTW, regarding Kaushal Modi’ question from last year — which seems to have been lost in the great WordPress Comment Void — if linum-mode isn’t loading for you, then it sounds like Emacs isn’t finding linum.el. Make sure that linum.el is in your site-lisp directory (or wherever you have configured Emacs to look for .el libraries).

    If you want to add a file outside of the default Emacs load-path list, try this:

    (add-to-list ‘load-path “c:/some/nonstandard/directory/linum.el”)

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.