News for hackers. Stuff that matters.
Re:Vim anti-patterns by tomn on Tuesday February 07, 2012 @04:16PM (#3563670)
These kind of articles always have a few new things in them, even of most of it is familiar -- I guess everyone just has a slightly slightly different set of indispensable tricks.

The most most useful Vim trick I've seen recently is "set relativenumber". This makes Vim show line numbers relative to the current line. This is awesome, because it lets you easily jump to any line you can see. eg. you can get to a line marked "9" above the cursor by pressing "9k".

It can be slightly tricky to get used to if you're used to absolute numbers (have to use gg more), but for me it's worth it.

Re:Vim anti-patterns by telemachos on Tuesday February 07, 2012 @06:03PM (#3564102)
I've tried relative numbers a few times in Vim, but always found it hard to adjust. But recently Jeff Kreeftmeijer wrote up a way to get the best of both worlds[1]: relative numbers in command mode and absolute numbers in insert mode or if Vim loses focus. Just another option to consider.

[1] http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vi...

Re:Vim anti-patterns by dasil003 on Wednesday February 08, 2012 @04:48AM (#3565922)
That's a good hack. Personally I just have F4 mapped to toggle between relative and absolute, but relative is the default. I rarely care about specific line numbers because if I'm looking at a stack trace for something I just jump directly with :#
Re:Vim anti-patterns by secoif on Tuesday February 07, 2012 @06:26PM (#3564189)
If you train yourself, you can get good at guessing the line numbers, plus is makes you feel godly when you correctly dd the 17 lines you want.
Re:Vim anti-patterns by tomn on Tuesday February 07, 2012 @08:54PM (#3564641)
That, or subtracting ;)

I swear the entire UI of Vim is made to make the user feel like a ninja.

Re:Vim anti-patterns by literalusername on Wednesday February 08, 2012 @02:16AM (#3565570)
I'm fairly sure the GP meant "dd", not "add".
Re:Vim anti-patterns by tomn on Wednesday February 08, 2012 @07:03AM (#3566232)
Ah, I meant subtracting the current line number from the target line number to get the number of lines to jump, instead of just guessing.
Re:Vim anti-patterns by literalusername on Wednesday February 08, 2012 @12:57PM (#3567600)
Got it. I think we ironically tend to underestimate our ability to estimate. I normally :set nonumber, and like secoif, I've impressed myself on numerous occasions with how well I'm able to estimate line counts and character counts. Give it a try -- you're likely to impress yourself too.
Re:Vim anti-patterns by secoif on Wednesday February 08, 2012 @05:32AM (#3566007)
Correct.
Re:Vim anti-patterns by alinajaf on Wednesday February 08, 2012 @05:08AM (#3565966)
I need to do more of this. At the moment I'm relying on visual mode way too much (i.e. select what I like, then delete it).