Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line numbers only in certain modes

Tags:

emacs

emacs24

Is there a way to get line numbering only in specific modes, i.e Python, Java, C++, etc., rather than in every window? I thought I saw something about this the other day, but I can't find it.

Currently I'm set up that the default is just to have linum-mode on persistenly. It's kind of annoying in the shell.

Thanks.

like image 235
Matt Avatar asked Dec 08 '13 03:12

Matt


2 Answers

Assuming you want to use it all major programming modes and you're using Emacs 24.x, you can use this snippet:

(add-hook 'prog-mode-hook 'linum-mode)
like image 56
Bozhidar Batsov Avatar answered Nov 10 '22 17:11

Bozhidar Batsov


I didn't turn linum on globally.

Instead I turn linum on for the major mode in which I want it. For example:

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

or simply:

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

Related here:

Turning on linum-mode when in python/c mode

and here:

Emacs Org-Mode: Turn off line numbers

like image 41
TacticalCoder Avatar answered Nov 10 '22 16:11

TacticalCoder