How to add a space between the line numbers and text content in Emacs?
Posted on In QAI 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?
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)))
Thanks a lot man, really helpful.
Since I’m using UTF-8 capable terminals all the times anyways, I put a box drawing character pipe, instead of a blank: “d│”.
Cheers