How do I increase the spacing of the line number margin in vim?

https://github.com/vim/vim/blob/master/src/screen.c#L2220

Looking at the code, it turns to be impossible (without patching the vim, obviously): vim always formats the line numbers to take up the whole available width, leaving just a single space afterwards (the "%*ld " format specifier in the code makes sure of that).


This bothered me, too; I hate having text crammed up against a block of solid color. It makes me claustrophobic.

Here's what I did as a workaround (in MacVim, but I expect the same technique will work elsewhere):

In your preferred colorscheme, set the background color of the line-number column to be the same as the background color for normal text, and the line-number foreground color to something low-contrast and unobtrusive (so it doesn't look like it's part of your normal text). I use white-on-black for normal text, and dark-grey-on-black for the line numbers:

hi LineNr  guifg=#505050   guibg=Black
hi Normal  guifg=White     guibg=Black

Admittedly, this doesn't fix the problem so much as hide it, but it's worked well for me.

Tags:

Vim

Margin

Macvim