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.
[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.
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.
@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!