3

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.

2

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

2

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)
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.