3

When using set number and set numberwidth I'd like to have the line numbers padded with zeros instead of spaces.

example:

0001
0002
0003

Can it be done?

  • 1
    Not unless you change Vim's source code. – romainl May 1 '16 at 14:22
3

AFAIK, this can only be done by changing the Vim source code and rebuilding.

The changes you need to make are as follows:

For zero-padded number, in src/screen.c on lines 2502 and 3712, replace:

char *fmt = "%*ld ";

with

char *fmt = "%0*ld ";

For zero-padded relativenumber, in the same file, on lines 2519 and 3725, replace:

fmt = "%-*ld ";

with

fmt = "%0*ld ";

Line numbers noted above are for the current version on Github, 7.4.1799.

  • 2
    From this answer: Be sure to use the canonical URL. You can get it for a particular commit by pressing the y key. The URL in your browser will change accordingly. – Jair López May 1 '16 at 15:49
  • @JairLopez Cool, I didn't know about that feature on github. I updated the URLs in my answer. – verb_noun May 1 '16 at 16:30

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.