tags:

views:

37

answers:

1

I would like that my linum-mode numbering is right aligned. The closest thing I've found is on emacswiki, but it doesn't work - it seems to left align the digits instead of right align it. The snippet is found here. Sorry for the horrible indenting, lisp is pretty alien to me :)

(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)))

Any ideas?

+2  A: 

Customize variable linum-format, for example to align on the right on 7 characters :

(custom-set-variables '(linum-format (quote "%7d")))
Jérôme Radix
I would have liked this a lot more if it'd been dynamically done, but once a file passes 1000 lines it doesn't matter anyways. Thanks! :) I settled for `%4d`.
monotux