4 ms·
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 in
by tomn 15y ago
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.
- telemachos 15y agoI'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-vim-for-super-fast-movement/ http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vi...
- dasil003 15y agoThat'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 :#
- secoif 15y agoIf 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.
- tomn 15y agoThat, or subtracting ;) I swear the entire UI of Vim is made to make the user feel like a ninja.
- literalusername 15y agoI'm fairly sure the GP meant "dd", not "add".
- secoif 15y agoCorrect.
- tomn 15y agoAh, I meant subtracting the current line number from the target line number to get the number of lines to jump, instead of just guessing.
- literalusername 15y agoGot 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.
- alinajaf 15y agoI 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).