8

I use relative line numbers along with an absolute line number for the current line:

set number
set relativenumber

The absolute current line number is always aligned to the left, and the help pages (or Google) don't seem to provide an option to change this.

Is it possible to prevent this left align, or will I have to learn to live with it?

enter image description here

12

From screen.c, win_line() function (around line 3707):

/* 'number' + 'relativenumber' */
num = lnum;
fmt = "%-*ld ";

The %- makes it left-aligned (See sprintf(3)). As you can see, this value is hard-coded.

If you really want this, you can modify it to:

fmt = "%*ld ";

and recompile. The result should be something like:

enter image description here

Of course, this might make a good candidate for an option/patch :-)

  • How about aligning all other non-current lines to the left? – Rafi B. Sep 5 '15 at 7:20
  • @RafiB. I don't understand your commment? – Martin Tournoij Sep 5 '15 at 10:50
  • taking your screenshot for instance, aligning the line numbers 1-2 and 1-3 to the left. – Rafi B. Sep 14 '15 at 10:56
  • @RafiB. Yes, that's possible, by modifying the source... – Martin Tournoij Sep 14 '15 at 10:58

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.