How can I add line numbers to Emacs?
Please explain, I'm an absolute beginner.
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.)
Add (global-linum-mode t) to ~/.emacs.d/init.el
linum-modeto the answer. – geekosaur May 06 '11 at 19:48(setq global-linum-mode t)is not working when I add this line to .emacs.d/init.el, I just change it to(global-linum-mode t)and it works. Any reasons why? – ZijunLost Dec 28 '15 at 02:15