Show line numbers in the left margin in Emacs
So, I recently started using emacs
as a text editor, instead of vi
. It didn’t seem easy to get things up straight at start. But gradually I understood why many experienced developers prefer emacs
: it is highly customisable and extensible.
vi
gives you easy to use command to show line numbers, :set nu
and you are done.
That is not the case with emacs
, and hence this blog post. You need to install linum package and enable linum-mode
for this.
Make sure you have the latest version of emacs
, at the time of writing 24.3,
so that you have emacs package manager ready. Add marmalade and melba to the package
archive list by adding the following to your ~/.emacs.d/init.el
.
|
|
Now list the packages using M-x list-packages
command.
You should get a list of packages like this.
Next locate linum
package using Ctrl-s
command.
You may have to repeatedly use Ctrl-s
to get the right package.
It would say display line numbers in the right margin.
Select and install that using arrow keys and return key.
You can enable linum-mode right away using M-x linum-mode
command.