I use this plugin relative-line-numbers of Fanael on Github. how to add extra spaces on the both sides of the relative number sides?

Form this

enter image description here

To this

enter image description here


From the documentation:

relative-line-numbers-format is a variable defined in ‘relative-line-numbers.el’. Its value is relative-line-numbers-default-format

The function used to format the line numbers. The function should take one integer argument: the line’s distance, in lines, from the current line, and return a string.

You can customize this variable.

You will have first to define somewhere in your configuration file, a function to use for formatting, for example:

(defun my-relative-line-numbers-default-format (offset)
  "The default formatting function.                                                                                        
Return the absolute value of OFFSET, converted to string."
  (concat " - " (number-to-string (abs offset)) " + "))

Then, you will have to call M-x customize-variable then type relative-line-numbers-format. You'll be shown a window inside with you can change the name of the function used for formatting, use your custom function defined above. Then you'll have to apply and save.

| improve this answer | |

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.