4

I knew this site would teach me more about my beloved vim :-) In posting a question/answer on how to delete large blocks without having to count lines, one of the answers taught me something I didn't know, that being relative line numbers along the lines of:

 2 This is line 1 1 This is line 2 3 This is line 3, the current line. 1 This is line 4. 2 Line 5. 3 Line 6. 

Now, if you wanted to delete lines 3, 4 and 5, you can simply add one to the relative line number (2) and use that to set the count, the command being 3dd.

However, adding one seems a bit obscure so I was wondering if you could configure the line numbers in relative mode to be more like this:

 2 This is line 1 1 This is line 2 3 1 This is line 3, the current line. 2 This is line 4. 3 Line 5. 4 Line 6. 

That way you could simply transcribe the number into the command without having to think about it.

2 Answers 2

20

Don't do that. A numbering system that goes from -1 to +1 without a zero in between is just asking for trouble.

As an alternative habit, I suggest d2j — "delete this line and the next two lines". That works both ways: d2k deletes upward.

A long-winded ex command version of that would be :+2d.

3
  • Accepting for the d2j which solves the problem. Commented Feb 19, 2015 at 8:49
  • What's the problem with line numbers going from -1 to +1? I can see how it could cause you trouble in mathematics, but in line numbers? Commented Feb 20, 2015 at 1:13
  • @Jerry The asymmetry between the upward and downward numbering schemes would be harmful, for example. It would make my suggested d2j vs. d2k confusing. Commented Feb 20, 2015 at 1:17
2

Maybe: d<number><CR>