Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that there's already a question of the same type on here, and I did take a look at it. The thing is, what is suggested there leads to line numbers being displayed right next to the code, with not a single space in between which annoys me a lot. Therefore, I wanted to try a different approach.

I'm trying to use the this code I found on the emacs wiki. I created the line-num.el file , put it in ~/.emacs.d/plugins and then modified the ~/.emacs file as follows:

(add-to-list 'load-path"~/.emacs.d/plugins")

(require 'line-num.el)

But when I start emacs, I don't see any line numbers.

share|improve this question
    
I don't know what the problem is, but seen this page? emacswiki.org/emacs/LineNumbers It lists several packages with discussion. – Tom Oct 15 '11 at 20:03

You could use linum-mode's linum-format variable to add a space on the margin: (setq linum-format "%d ")

share|improve this answer

A couple of things. First, to properly require the package, you don't use the .el at the end:

(require 'line-num)

Second, you need to turn it on, generally by using a hook:

(add-hook 'c++-mode-hook 'turn-on-line-numbers-display)

Add a line for each of the programming modes you want to have line numbers.

That said, the line-num package says that the setnu package provides better functionality, so you might want to try that, as well as the setnu+ addition. See the wiki for how to get it and install it.

And, there's the built-in linum-mode that you found. To turn that on for all buffers associated with files, you can do:

(add-hook 'find-file-hook 'linum-on)
share|improve this answer
    
I managed to use the built in line number module linum-mode, but I wanted to modify the .emacs file so that that command is run on startup. Could you tell me how to do that? Thanks! – efficiencyIsBliss Oct 25 '11 at 0:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .