Hacker News new | past | comments | ask | show | jobs | submit login
Numbers.vim - A vim plugin for better line numbers (github.com/myusuf3)
38 points by rdegges on Sept 9, 2012 | hide | past | favorite | 20 comments



Already posted a couple of months ago: http://news.ycombinator.com/item?id=4172099


Lately it feels like the HN front page is stuck in a loop.


I heard the same thing happened to another link aggregator.


Using a plugin for this seems... unnecessary.


You can obtain similar functionality by adding the following to your .vimrc: https://gist.github.com/3012145


You shouldn't ever have to count lines in vim. The five line deletion example could have been done as:

  10dG
Which would delete from the cursor to the tenth line.


d5j

delete five from where you are- inclusive


This still means you would be counting 5 lines whereas I'm just specifying what line to delete to.


I am subtracting, but your point is valid.


Why is it better? And better than what?


There are two types of line numbering in vim, relative and absolute. The former counts the lines starting from the vertical position of the cursor, backwards and forwards. The latter starts at the top of the file to the bottom of the file.

Vim has several ways to move and edit a file. For example, to go to a specific line, you would use <n>gg and you would jump to that line. This is useful for navigation as well as selection.

There are likewise commands that are relative from the cursor's position. dd and yy come immediately to mind, as well as the h-j-k-l commands. Knowing how many lines you need is augmented from the relative line numbering.

The key here is Vim doesn't have an easy way to switch from one to the other, except through manually typing commands like `set relativenumber` and `set number`. The plugin switches the number count based on what mode you are in.


I believe the general theory is relative line numbering helps you when in normal mode. If you want to manipulate a chunk of lines, sometimes you revert to counting them then doing something like <n>yy. With relative line numbering the counting is effectively done for you.

But to me, I try to avoid counting arbitrary lines and instead try and do something like y/<unique marker> or ya{ or whatever.


This is awesome. I just made an ebuild for it : https://plus.google.com/110857536631648345380/posts/4NeGmXfM...


Does this make it so that highlighting in Terminal (prior to copying) only selects the text?

I had line numbers set till it turned out that when I selected a bunch of text for copying selected the line numbers too. Ugh.


Can anybody tell me what relative numbers are useful for other than navigation? I find Easymotion the state-of-the-art plugin for navigation.


Yeah, easymotion does make counting words/lines seem rather redundant. I'm just hoping that they'll extend easymotion so I don't even need to think about what I'm jumping to i.e. I hit leader leader and every non-white character is indexed to jump to.


Anyone have a screenshot of how this looks?


The HN submission would be better as this page: http://myusuf3.github.com/numbers.vim


Awesome, even better. Thanks!


why not just use visual mode?? then you can see the lines you are deleting, copying / cutting




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: