emacs 23.1以后的版本都默认包含linum,只需使用M-x输入命令linum-mode再按回车即可显示行号.详见下文.
(转自https://www.metalevel.at/linum/linum.html)
linum lets you display line numbers to the left of Emacs buffers.
![linum-mode screenshot](https://i-blog.csdnimg.cn/blog_migrate/553597356f7e6f814b580257cd0e3a66.png)
As of Emacs 23.1, linum ships with GNU Emacs. You can enable it with M-x linum-mode RET
You can also download either:
- linum.el for Emacs >=22, or
- compat/linum.el for older Emacs versions and XEmacs
Copy the appropriate linum.el to your load-path and add to your .emacs :
(require 'linum)
Then toggle display of line numbers with M-x linum-mode RET
另外,全局开启的方法如下: .emacs 中写入
(global-linum-mode 1) <span class="comment-delimiter" style="color: rgb(178, 34, 34);">; </span><span class="comment" style="color: rgb(178, 34, 34);">always show line numbers</span>保存即可。
注:.emacs文件一般位于用户的home目录下,windows下需要设置HOME环境变量,HOME环境变量所指的目录即为home目录.