3 ms·
Line number are super helpful for navigating in vim, though. :54 when you’re on line 20 is much faster than any alternative.
by Ancapistani 6y ago
Line number are super helpful for navigating in vim, though. :54 when you’re on line 20 is much faster than any alternative.
- repsilat 6y agoSome folk like `34d` so they don't need to press shift. And sometimes set relative line numbers so they don't need to do the subtraction. Others just search for known text, which IMO is a habit I need to get into. I "got" hjkl after I disabled the cursor keys for a day, but I never followed up and disabled hjkl (or maybe even w and b!?) to get super efficient.
- strogonoff 6y agoI have never considered disabling hjkl, quite an interesting idea.
- coliveira 6y agoYou can just use 54gg, no shift involved.
- alpaca128 6y agoI often navigate with the search. It's fast as I usually know where I want to go. Also with the right setting(I think incsearch) Vim immediately jumps to the first result as you type, so I often use search to quickly peek at some code and then jump back with Esc when it doesn't warrant splitting the buffer. But I do still struggle a bit with moving within the line - w and b tend to "get caught" in long series of different symbol categories that Vim will all see as separate words/tokens. At least I got my setup with the "camelcasemotion" plugin working, which is a great help with long identifier names.
- strogonoff 6y agoI see, I suppose it depends on one’s habits then. Personally I’m used to roughly approximating relative jumps or using search to arrive at the desired identifier, but then I wouldn’t call myself especially efficient. The only time I find using :number is when I am exploring a codebase elsewhere, e.g. using GitHub’s web interface, and want to jump to a particular line in Vim to make edits—rarely happens.
- adrianmonk 6y agoI would type "8j8j8j8jjj". I type "8j" (and "8k") a lot.
- leppr 6y agoI bind those commands to "shift-j" and "shift-k" and heavily abuse them. It's not pretty, one could argue that the mouse is more efficient for such movements, but for me it's faster in practice than moving my hand to the mouse/trackpad, or than looking up a line number (either absolute or relative) and then typing it. And it has no mental burden.
- jacknews 6y agoI use H, M, L to move the cursor to the top, middle and bottom of the screen, and ctrl-f and ctr-b to scroll half a page, which drags the cursor along for the ride if it would otherwise be offscreen.