代码之家  ›  专栏  ›  技术社区  ›  monotux

将行号与linum模式右对齐?

  •  9
  • monotux  · 技术社区  · 14 年前

    我想要我的 linum-mode 编号是右对齐的。我在emacswiki上找到了最接近的东西,但它不起作用——似乎起作用了 左对齐 数字而不是 右对齐 是的。 The snippet is found here . 很抱歉,我觉得lisp很陌生:)

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

    3 回复  |  直到 14 年前
        1
  •  4
  •   Jérôme Radix    14 年前

    自定义变量linum格式,例如在7个字符上右对齐:

    (custom-set-variables '(linum-format (quote "%7d")))
    
        2
  •  20
  •   aculich    13 年前

    你可以用这个值 'dynamic

    (custom-set-variables '(linum-format 'dynamic))
    

    或者您也可以通过以下方式进行自定义: M-x customize-variable RET linum-format

    dynamic . 没有简单的方法可以做到这一点,但是可以使用 defadvice 周围 linum-update-window 我从代码中改编的函数 动态

    (defadvice linum-update-window (around linum-dynamic activate)
      (let* ((w (length (number-to-string
                         (count-lines (point-min) (point-max)))))
             (linum-format (concat "%" (number-to-string w) "d ")))
        ad-do-it))
    
        3
  •  -2
  •   Paul Fleming    11 年前

    更改亚麻并将字节文件编译为.elc。

    对于emacs 23.3

    第143行亚麻

                      (concat "%" (number-to-string w) "d" " | ")))))
    

    我将默认的fort更改为“xxx |”。