Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jump to line in vim with relativenumber on

Tags:

vim

ide

In a normal situation it's possible to look at the line number and use [number]G to goto that line. But I like to work with the setting relativenumber on. The disadvantage is that I can't jump to lines anymore by looking at the displayed line number.

Is it possible to redefine the behavior of [number]G to fix this? Also, would it be possible to make the current line number 1 instead of 0 with relativenumber on? And how?

like image 881
Jasper Avatar asked Oct 01 '11 15:10

Jasper


People also ask

How do you jump a line in vim?

If we are in the vim editor, then simply do this, “Press the ENTER key, write the Line number, and press Shift+ g”: Again the output is the same.

How do I toggle relative numbers in vim?

Relative Numbering is not turned on by default in vim, which means that you are probably turning it on through your ~/. vimrc file or one of your plugins. Look for set relativenumber or set rnu . To turn it off for the current vim session you would simply run set norelativenumber or set nornu for short.

What is relative number in vim?

When you display relative numbers in Vim, each line is numbered by its distance from the cursor. Take a look at the position of the cursor in the image above. This position is marked as 0. Accordingly, lines above and under the cursor are labeled as 1, the next ones 2 and so on.


1 Answers

You can simply [number]j or [number]k to do this.

like image 133
Tamás Szelei Avatar answered Nov 09 '22 07:11

Tamás Szelei