我想我的linum-mode编号是正确对齐的.我发现的最接近的东西是在emacswiki上,但它不起作用 - 似乎左对齐数字而不是右对齐它.该片段在此处找到.抱歉可怕的缩进,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)))
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
acu*_*ich 19
您可以使用该值,'dynamic因此您不必选择任意数量的填充:
(custom-set-variables '(linum-format 'dynamic))
Run Code Online (Sandbox Code Playgroud)
或者您也可以使用以下方式对其进 M-x customize-variable RET linum-format
此外,@ asmeurer询问如何在数字后添加空格dynamic.没有简单的方法可以做到这一点,但它可以使用我从代码中修改defadvice的linum-update-window函数来完成,该函数dynamic已经在该函数中:
(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))
Run Code Online (Sandbox Code Playgroud)
自定义变量 linum-format,例如在 7 个字符右侧对齐:
(custom-set-variables '(linum-format (quote "%7d")))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2987 次 |
| 最近记录: |