How to add a space between the line numbers and text content in Emacs?

I use Emacs in console. The linum-mode displays the line numbers just well. However, in the console, there is no space between the line numbers and the text content, which makes it a little messy some times. How to add a space between the line numbers and text content in Emacs?

asked Mar 29, 2014 by Eric Z Ma (44,280 points)

1 Answer

 
Best answer

If you are using the linum-mode for displaying the line numbers, you can define your own linum-format to specify the format by adding the space in your ~/.emacs:

(require 'linum)
(global-linum-mode t)
;; use customized linum-format: add a addition space after the line number                                                                      
(setq linum-format (lambda (line) (propertize (format (let ((w (length (number-to-string (count-lines (point-min) (point-max)))))) (concat "%" \
(number-to-string w) "d ")) line) 'face 'linum)))
answered Mar 30, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...