Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I add line numbers to Emacs?

Please explain, I'm an absolute beginner.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

If you're running it in default mode, it's in the menu: Options > Show/Hide > Line Numbers. Then Options > Save Options to save it for future sessions.

If you're running it in a terminal (emacs -nw), then it's M-x line-number-mode. M- is usually the Windows key, but may be Alt, or you can press Esc followed by x.

(Edit: The above only affects the mode line. For line numbers in the margin, you want M-x linum-mode, or more likely (setq global-linum-mode t) in your ~/.emacs.)

share|improve this answer
1  
That only displays the current line number in the mode line –  Florian Diesch May 6 '11 at 19:44
    
@Florian: Good catch. I added the instructions for linum-mode to the answer. –  geekosaur May 6 '11 at 19:48
    
Ok, you've been faster - deleted my answer –  Florian Diesch May 6 '11 at 19:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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