News for hackers. Stuff that matters.
Re:Vim Tips For Intermediate Users by chrismorgan on Tuesday May 19, 2015 @11:00PM (#9574428)
I’ve found relative line numbering to be distracting, and I find myself wanting absolute line numbering far more often. The reason that people want relative line numbering is almost always for relative motions, e.g. `6j`. But I find that this is seldom actually all that useful; there are various alternatives; here are a few:

- `}` to go forward by paragraph.

- `zj` to go down to the next fold.

- `gg` and `G` both accept a count (with which they are identical), so that `50gg` means “go to line 50”, and so absolute line numbers suffice though the command will typically be a little longer; of course, unlike `6j`, this will go to the start of the line if 'startofline' is not unset, so it’s not always ideal, but I find myself rather good at knowing at sight how many lines down and up I need to go anyway.

Re:Vim Tips For Intermediate Users by isbadawi on Tuesday May 19, 2015 @11:05PM (#9574441)
You can use a hybrid of absolute and relative numbering by setting both the 'number' and 'relativenumber' options (in vim 7.4). It displays the absolute number of the current line (instead of 0) but relative numbers of the other lines.
Re:Vim Tips For Intermediate Users by sondr3 on Wednesday May 20, 2015 @12:11AM (#9574611)
Care to give any links to this? This is probably my biggest annoyance with Vim right now, how my current line is 0 and having to add 1 every time I do any operation gets old quick.
Re:Vim Tips For Intermediate Users by frankerz on Wednesday May 20, 2015 @12:18AM (#9574645)
I think what he means is just put both

set relativenumber

set number

In your .vimrc

Re:Vim Tips For Intermediate Users by aleek on Wednesday May 20, 2015 @12:22AM (#9574659)
Re:Vim Tips For Intermediate Users by userbinator on Tuesday May 19, 2015 @11:46PM (#9574537)
I use :<line-number><enter> to go to a specific line; it has the advantage of showing the digits of the line number as it's entered.
Re:Vim Tips For Intermediate Users by palmer_eldritch on Wednesday May 20, 2015 @10:26AM (#9576489)
If you set the 'showcmd' option, the command you're currently typing is displayed on the last line of the screen (same as command line) on the right.

Of course, saving one keypress on this isn't a big deal but it's nice sometimes to be able to see the command you're typing.

Re:Vim Tips For Intermediate Users by kristiandupont on Wednesday May 20, 2015 @12:58AM (#9574754)
At work I use VsVim and this plugin https://visualstudiogallery.msdn.microsoft.com/74d68e2b-ff64... allows both simultaneously, which suits me best. I have not been able to achieve that in vim yet though.
Re:Vim Tips For Intermediate Users by realyze on Wednesday May 20, 2015 @12:34AM (#9574694)
Fair enough. I kinda switch between those two. Like, when I need to yank 5 lines from the middle of a function, I find it quite comfortable to see the relative numbers.
Re:Vim Tips For Intermediate Users by johnmaguire2013 on Friday May 22, 2015 @01:50AM (#9586708)
Or just `:<number>`?