Emacs Line Numbers

They Count

If you want to display line numbers in a buffer, there are a couple of ways of doing this. You can use linum.el, kindly made available by Markus Triska. Download and dump it in your .el elisp directory.

Add the following to your .emacs config file:

(require 'linum)

To activate line numbers, do:

M-x linum-mode

To de-activate line numbers, do:

M-x linum-mode

This code displays line numbers to the left of the buffer. Its for display purposes only. The file remains unchanged.

Want to add line numbers to your buffer content? Try this:

M-x replace-regexp [Return]
^.*$ [Return]
\# tab \& [Return]

Move cursor to start of buffer before you enter code. Otherwise numbers will start from current line.

There are other functions available at EmacsWiki. Go take a look.

You can also display line numbers on the mode line. Add the following to your .emacs file.

; Enable line number on mode line
(line-number-mode 1)

Might as well add the column while your there!

; Enable column number on mode line
(column-number-mode 1)