Give :set relativenumber a try

Those who have seen me give vim-related talks in the past may have heard that I’m against vim’s relativenumber setting.

Well my friends, I’m here to tell you that I was wrong. relativenumber is awesome, and we should all be using it.

Here’s how I wield relativenumber's awesome power:

  • [count]j
  • [count]k
  • [count]<
  • [count]>
  • [count]c
  • [count]d

Pretty much anything you want to do to multiple lines, you can do faster with relativenumber. In fact, I’m starting to think that using visual mode might be a vim antipattern.

Thanks to @jferris for showing me the light.


Why where you against relativenumber in the past? I’m guessing you had reasons. Maybe the reasons would still apply in some situations?

Good question!

You’re right, the reasons still do apply:

  1. It makes things a little harder when pairing. (“Change line 7, no 8, no 9”)
  2. It’s slightly more annoying to locate which line of your test failed. I just use [line number]G to jump there, but it’s not as easy as scanning.


Could you give a snippet from your .vimrc of this section… want to see how the [count]j ,etc is setup… newbie =)

[count] just refers to me putting a number before the command. So I see that I want to move to a line 9 lines down (easy to see thanks to relativenumber), so I type 9j. That’s it.

My vimrc just has set relativenumber in it. You can see my dotfiles here if you like:

Thanks I will give it a try…

That’s cool. You can do a lot of the same with normal line numbers. Here are the corresponding commands:

  • [line number]G
  • <[line number]G
  • [line number]G

  • c[line number]G
  • d[line number]G

So I agree that you can do things a lot faster if you stop using visual mode. I disagree that it’s relativenumber that’s making things faster.

1 Like

@kenearley Didn’t know you could do that. Thanks!

I just went back to the vim default (no numbers) as an experiment. Too early to say whether it’s painful.

I still plan to use :linenumber when I need to reference the line for a failing test and will be giving @kenearley’s tips a try, too!

I read jeff kreeftmeijer’s article on super fast vim movement, then I vundled his number toggle plugin very cool… I am adjusting to (toggling helps) but then again I am newer to vim so it is just another speed trick to me =)

:relativenumber tends to be faster for me because the numbers are smaller. If you’re on line 80, it would be >85G to indent the next 5 lines with :number, but just >5j with :relativenumber. It saves me a keystroke with almost every motion. Two if you include shift.

No line numbers? Do you have any expected wins in mind or are you just interested in trying stock vim?

Not sure yet. Just removing it to make sure I understand where the pain is.

Did you guys notice that if you set both things set relativenumber and set number you will get a hybrid of both things?
Something alone this lines:


Hope this help :wink:


@Rafael_George Thanks for sharing! This is a new feature in Vim 7.4. I have yet to switch from 7.3, but this is one of the main reasons I am considering it (the regex engine was also sped up a great deal which sounds nice).

This post has some added detail on the new hybrid mode.


My co-worker that introduce vim to me also uses relative number, it’s very easy to delete, move(indent), i’m still trying to go up and down using numbers e.g. 8j, 5k, still very new to vim like 3 weeks :), can’t get myself to not use it, tried to go back to sublime, rubymine.

Also using thoughtbot laptop and dotfiles made the switch smoooth!