Live data from Hacker News

Better line numbers for Vim

myusuf3.github.io

1–10 of 46 posts

Re: Better line numbers for Vim

#4
If the author of the video is reading this: The problem you have with the background color in vim in the beginning of the video can probably be cleared up by making sure your TERM is set correctly.

TERM=screen-256color-s cleared it up for me using tmux/urxvt (with 256 colors).

(Also, great plugin!)

Re: Better line numbers for Vim

#5
Nice job with your first vim script!

That said, VIM patch 7.3.787 provides a 'better' solution by replacing the current line's number with the absolute number (because seeing 0 on the current line provides nothing meaningful) IMHO:

  with 'relativenumber' can't see the absolute line number
ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.787

Re: Better line numbers for Vim

#6

This is kinda life-changing. You have now made the use of numeric count prefixes to line-wise operations actually useful. 20dd for example. Delete groups of lines quickly and with precision, without guessing how many lines are involved.

I didn't even realize relative numbering was a built in feature of vim - learned by reading the plugin source. Vim is the gift that keeps on giving.

Re: Better line numbers for Vim

#8
I was at one point very interested in the same idea. I wanted relative line numbers and absolute line numbers integrated together. So, I created a patch, called it `dnu` for "dual line numbering", and sent the suggestion to Bram Moolenaar.

Here's what it looked like: http://i.imgur.com/NTwwB.jpg

Here was the patch. I wrote it back in 2011: https://code.google.com/r/justinvh-vim/source/detail?r=c2479...

Ultimately Bram Moolenaar sent me a reply:

"""

Justin,

I think the audience for this would be too small.

- Bram

"""

However, in 7.3.787 (Jan 2013) a patch was introduced which showed the current line number in :rnu instead of 0. That's definitely in the direction that this patch was going in.

So, I didn't get a patch in, but on the plus side, I did learn a bunch about vim's source code.

Re: Better line numbers for Vim

#9

This is kinda life-changing. You have now made the use of numeric count prefixes to line-wise operations actually useful. 20dd for example. Delete groups of lines quickly and with precision, without guessing how many lines are involved.

I didn't even realize relative numbering was a built in feature of vim - learned by reading the plugin source. Vim is the gift that keeps on giving.

I went to relative numbering a while ago and I can't go back. It's awesome.

The only problem is that it's new in vim 7.3, so there are times where I'm forced to use an older version of vim and can't use the feature. I'll look up 10 lines, see "583" and automatically hit 583k without thinking. Not a big deal, and of course I can just do 583G to fix my mistake, but it's definitely some combination of funny and irritating.

Re: Better line numbers for Vim

#10
post #8

I was at one point very interested in the same idea. I wanted relative line numbers and absolute line numbers integrated together. So, I created a patch, called it `dnu` for "dual line numbering", and sent the suggestion to Bram Moolenaar. Here's what it looked like: http://i.imgur.com/NTwwB.jpg Here was the patch. I wrote it back in 2011: https://code.google.com/r/justinvh-vim/source/detail?r=c2479... Ultimately Bra…

This looks quite useful to me.

Feature request: allow the user to select separate colors for the relative and absolute line numbers, and for the slash. So three separate colors in total. That would make it easier to read.

Another idea is to have relative line numbers on the left side of the screen, and absolute line numbers on the right (or vice-versa).

Post reply on HN