36

I have a problem with my colorscheme in vim:

alt text
(source: tinygrab.com)

The line numbers are too close to the code. How I can increase the width of the line numbers' right margin?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Sasha Koss
  • 15,129
  • 4
  • 20
  • 27
  • I'm pretty sure there's no option to affect that spacing. I'm surprised you think they're too close - that's the same one-character spacing every vim user has - but I'm aware it's a personal preference. I'd suggest making the numbers a lower contrast to get some aesthetic distance but it looks like you've already done that. – Cascabel Mar 28 '10 at 05:32
  • Why don't you try making it so every line displayed has a space at the beginning of it (giving the appearance of a gap). Just make sure to remove that line on all save commands! – puk Feb 16 '12 at 22:41

6 Answers6

20

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.

Bill Odom
  • 4,143
  • 24
  • 20
16

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).

Ethan McTague
  • 2,236
  • 3
  • 21
  • 53
Einar Lielmanis
  • 347
  • 1
  • 4
14

You can add the following line in your "~/.vimrc":

set nuw=6

Where "6" specfies the width of the column in terms of number of characters. Replace with a smaller or large number as needed. Only works with more recent (>=7?) versions of Vim, I think.

Jeet
  • 38,594
  • 7
  • 49
  • 56
1

%left 5 in the vim terminal (% whole document, left distance code to linenrs, 0-infinity distance in monospace (= number of columns))

Michael
  • 63
  • 4
1

Here is solution 2 (ref to how to change the left margin in gvim)

Solution 1 (like %left 5 )just adds 'spaces' into the code area. I guess it does the same done by the threadstarter ...but it does not the answer the original question.

Solution 2: foldcolumn does the trick (foldcolumn is the column left from the linenumbers) In exec mode :set foldcolumn=12 If you want to change the color too (like in the ref) hi FoldColumn guibg=#003f3f (in the ref its FoldColumns, thats wrong).

Michael
  • 63
  • 4
1

Add the following line to you init.vim file.

autocmd VimEnter * :%left 5