Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 3 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).

share|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

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.

share|improve this answer
    
+1. Worked for me with VIM on windows. The accepted answer didn't work for me. –  Lord Tydus Sep 22 '12 at 16:46
    
Accepted answer didn't work for me either. –  Macario Apr 3 '13 at 1:17
    
This plus autocmd BufLeave * set number (set back to normal numbering when leaving buffer) worked for me too. –  alxndr Feb 8 at 9:24

This usually happens when you have both numbering, and relative numbering turned on in your vimrc:

set nu
" maybe lots more configuration here or in other sourced config files
set rnu

For some reason, this works in the first buffer/tab, but not in subsequent buffers/tabs, so the solution is to just have one or the other set but not both:

" turn on line numbering (either relative (rnu) or traditional (nu))
set rnu

Other answers get around the problem with your vimrc file but don't fix it, but they work also.

share|improve this answer
    
This was the solution to my problem. Thanks, man! –  Jessie A. Morris Feb 1 '13 at 21:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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