← Back to Upcase

The Art of Vim: Relative Number

(Upcase ) #1

This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/relative-number-with-ben-orenstein

(Ruslan Bilych) #2

Before “set relativenumber” put “set number” and instead zero you will have current line number.

set number
set relativenumber

42 cursor here

(Geoff Harcourt) #3

@rbilych, this is a great tip. This is one of my favorite (relatively recent) Vim features, as it gets you the best of both worlds.

(Wendy Lee) #4

I use something slightly different. With configuration like:

set relativenumber 
set number
autocmd InsertEnter * :set number norelativenumber
autocmd InsertLeave * :set relativenumber

The relative number is used in visual mode, but once entering the insert mode, it becomes the absolute number.

Hope that helps someone!

(Geoff Harcourt) #5

Wow, that is really cool. Do you notice any sluggishness when you enter and leave normal mode? I am going to give this a try in my dotfiles.

(Yepeng Fan) #6

That is super cool. Extremely useful. Awesome solution to combine number and relative number together.

(Wendy Lee) #7

sluggishness? No, I haven’t noticed anything particularly different than before using this set of config… But I’ll keep an eye on it! Thanks!

(beersheep) #8

Love this episode! I have a question, plus and minus don’t work for me. why is that?

(Jon Seidel) #9

Love it! Thanks…