help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to have line numbers start at 0?


From: Teemu Likonen
Subject: Re: how to have line numbers start at 0?
Date: Thu, 27 Aug 2009 12:37:23 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

On 2009-08-27 02:25 (-0700), Xah Lee wrote:

> with emacs 23, is it possible to have line numbers on the margin start
> at 0?

Do you mean like this:

    (setq linum-format #'(lambda (number)
                           (format "%3d" (1- number))))

Or with dynamic width:

    (setq linum-format #'my-linum-format)

    (defun my-linum-format (number)
      (format 
       (let ((w (length (number-to-string
                         (count-lines (point-min) (point-max))))))
         (concat "%" (number-to-string w) "d"))
       (1- number)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]