I like the relative number setting. I'm refactoring code at the moment (translation: explodicating 5 year old terrible methods and replacing them with nice code) and I find it useful to have the setting active on files as I open them

I frequently either open multiple buffers or use a client/server vim to contain all my open buffers/files and have noticed that the relative number only seems to apply to the first buffer (and not the remaining buffers when I have set rnu in my .vimrc file.)

Is it expected behaviour for rnu to only initially apply to the first buffer until you manually set it?

link|improve this question
feedback

3 Answers

up vote 0 down vote accepted

Yes, it is expected behavior, unless you explicitly set it globally with ":setglobal":

:setglobal relativenumber

See ":help :setglobal" and ":help 'relativenumber'" (with the single quotes as part of the command).

link|improve this answer
Ah that makes total sense thank you. I never considered setglobal – connrs Mar 19 '11 at 8:50
Did you try it? It's not what the docs say and it's not how it behaves here. – user112553 Jun 8 '11 at 3:37
feedback

No, it isn't expected behavior. If you set something, it applies both locally and globally.

Command                   global value    local value

set option=value          set             set
setlocal option=value     -               set
setglobal option=value    set             -
set option?               -               display
setlocal option?          -               display
setglobal option?         display         -

(Table to be found at the end of :help :setglobal.)

That's exactly what I'm seeing here, too. I set rnu in my vimrc once and it applies to all new buffers, windows, and tabs.

Try :verbose set rnu? | verbose setg rnu? when and where it ceases to work to find out what last changed it.

link|improve this answer
feedback

I am not sure if you want the same behavior as me... to have all buffers use relativenumber by default. If that is the case then you would think set relativenumber in .vimrc would work but it doesn't. Instead I used autocmd BufEnter * set relativenumber.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.