1

Emacs for some reason did not vacate equal spaces for each line number, So the lines were starting at different places which made it harder to keep track of alignment. It wasn't just the relative mode which had this problem, even the absolute mode does. Linum mode is quite heavy when compared to display-line-numbers.el.

| improve this question | | | | |
  • 2
    If there is an issue with display-line-numbers-mode you should report it via M-x report-emacs-bug RET. – Basil Jan 28 at 12:23
  • @Basil I am not sure if it's a bug or the intended behavior. – sidharth arya Jan 29 at 14:19
  • 1
    There is no harm in submitting a bug report you are unsure about. Either way I suggest you provide more information, e.g. in the form of diagrams, screenshots, or a screencast. – Basil Jan 29 at 14:22
1

This is what fixed my issue. All this is doing is, when the buffer is being setup for reading it would read the last line number and add the width of the number as the display-line-numbers-width.

(defun display-line-numbers-equalize ()
  "Equalize The width"
  (setq display-line-numbers-width (length (number-to-string (line-number-at-pos (point-max))))))
(add-hook 'find-file-hook 'display-line-numbers-equalize)
| improve this answer | | | | |
  • 1
    Leaving display-line-numbers-width to the default nil value should do the same thing. If it does not, you should report it. – NickD Jan 28 at 16:27
  • @NickD So the help menu shows this. The default value of nil means compute the space dynamically. I am not sure what dynamic means in this context, per buffer or per line? – sidharth arya Jan 29 at 14:18
  • 1
    Actually, I was wrong: it does not do the same thing. "Dynamic" means that it leaves enough space for the longest visible line number in the buffer. When you scroll down and you get to longer line numbers, the display will shift to accommodate them. – NickD Jan 29 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.