Line numbers in certain modes only

Is there a way to get line numbering only in certain modes, like Python, Java, C ++, etc., and not in every window? I thought I saw something the other day, but I can’t find it.

Currently, I am configured to only linum-mode persistently by default. It is annoying in the shell.

Thanks.

+7
emacs emacs24
source share
2 answers

I have not enabled linum globally.

Instead, I enable linum for the main mode in which I want. For example:

 (add-hook 'clojure-mode-hook '(lambda () (linum-on))) 

or simply:

 (add-hook 'clojure-mode-hook 'linum-mode) 

Related here:

Enabling linum mode in python / c mode

and here:

Emacs Org-Mode: disable line numbers

+4
source share

Assuming you want to use all the basic programming modes, and you are using Emacs 24.x, you can use this snippet:

 (add-hook 'prog-mode-hook 'linum-mode) 
+12
source share

All Articles