12

In vim, I like using relative linenumbers to see how many lines I need to yank, delete, whatever.

However, when using relative linenumbers, the current line is 0, which means, if I want to yank until the line with number 3, I have to type 4yy, which is sort of counterintuitive and is slowing me down.

Is there a way to display relative linenumbers starting with 1 instead of 0?

Machavity
  • 30,841
  • 27
  • 92
  • 100
Pmarcoen
  • 1,216
  • 4
  • 20
  • 33

3 Answers3

18

I'd say, work with the system. Instead of using a 'repeat' you could modify to use the motion as intended:

y3j instead of 4yy

You'll notice that the yank command takes a motion. yy is only there as a shorcut should you not want a motion (by definition it takes the current line).

In a sense, doing 4yy is a little bit akward ('4times' take this whole line; You are relying on the fact that the implict motion is effectively multiplied by the repeat, it isn't natural since the motion was implicit).

On the plus side, you could even combine it: 4d3j (delete 3linesdown 4 times in a row, not a very useful example)

sehe
  • 374,641
  • 47
  • 450
  • 633
  • Learning how to use motions would also enable you to delete/copy 4 lines upwards rapidly (y4k), instead of having to first move the cursor up four lines and then use 4yy to copy downwards. – joelostblom Feb 19 '16 at 12:41
  • Apparently, the keyboard button tag is not supported in comments. Here is a more legible version - Learning how to use motions would also enable you to delete/copy 4 lines upwards rapidly (`y4k`), instead of having to first move the cursor up four lines and then use `4yy` to copy downwards – joelostblom Feb 19 '16 at 12:49
0

AFAIK no... or you can check out vim and modify it's source code.

Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
0

No, it's not possible because the line numbers are relative. First line below current line is rightly numbered 1 and so is the first line above current line.

Agree that you have to do that little math when you are working with commands like yy, dd etc.

ronakg
  • 4,038
  • 21
  • 46