I use vim + mouse unfortunately because it is quicker unless there is a better way?
I use vim + mouse unfortunately because it is quicker unless there is a better way?
oooh. I have a treat for you! Check out "hybrid line numbers". I thought they would be weird when I heard about them, but they're awesome, and I never need "absolute line numbers". But the linked article shows you how to set up toggling if you need them.
Basically, they look like this:
3 Lorem ipsum dolor sit amet,
2 nunc in iaculis ipsum.
1 Suspendisse dapibus odio erat,
98 non varius nulla porttitor at. // <-- You are here
1 Nullam in convallis elit.
2 Sed nec venenatis ligula.
3 consectetur adipiscing elit.
4 Sed hendrerit ac ante sed viverra.
In this example, your cursor is at line 98 and so shows the absolute line number. The other lines are relative to your current line. If you want to go down to the line that starts consectetur, you see that it is below you 3 lines. You have to type 3j. If you need to find a specific line number, say 24, type :24Here's an article on them: https://jeffkreeftmeijer.com/vim-number/
If you're looking to use the 20j stuff, you can `:set relativenumber` so that vim shows you line numbers relative to the selected line to avoid counting. I couldn't get used to it.
There's also Hop[0] if you want to go the plugin route.
I want both, dammit!
/ or ? to search forward or backward.
C-f and c-b to go a full page. U and d are half.
But for me it’s not only about speed. I guess it just feels nice to use the keyboard, even when it’s a little slower.
But when you do need to move by lines, `set relativenumber` is very helpful. I have both `set number` and `set relativenumber` in my Vimrc, so I get relative numbers for all other lines except the current one. For the current line, the absolute line number in the file is displayed (which is more useful than the relative "0").
I try never to second guess why someone wants to know something, and if I answer at all, to answer the direct question. Otherwise it might come off as patronizing and gate-keeping.
As an asker, I'm much more open to hearing the answer to an unasked question when I have the answer to my asked question.
My least-favorite genre of dev answer is Q: "How do I X?" A: "Don't X. Y instead."
Also, part of the awesomeness of Vim is that it's personal, how someone uses it. If information is structured in lines in someone's mind, and it makes more sense for them to navigate that way, they aren't doing it wrong.
otherwise ctrl-f and u coupled with zz to center it
gd for go to definition.
using { and } for paragraph navigation is also useful. / is nice for words you know coupled with n and N
and using something like an outline is also nice to use when visually selecting.(i've been using neovim as a backend for vscode so this is built in) and if you use vscode they have a nice go back out feature too ctrl + - (which i forget what it is in vim but probably gb if i had to guess but you are limited to how vim works in that regard.
It's pretty nice, but to be honest I just use `/` and `n` a hell of a lot. And `j` is probably my most used character. :)
Don't? Just turn on line numbers with `set nu`. Add it to your `.vimrc` for a default. In a pinch where you need to copy/paste graphically in your terminal and don't want the line numbers on? `set nonu` to turn them off again.
Sibling comments also have great solutions/different ways of navigating.
The way I remember them is (H)igh, (M)iddle, (L)ow
Also setting fold to indent and collapsing the whole file with zM is super helpful for navigating large files.
Lastly I use searching a lot with / or ? To just type the pattern I'm looking for # to search for the word under my cursor.
Say I want to go up by 13 lines and on the 4th word:
Step 1: Scan visually on the left gutter for a line number (relative or not)
Step 2: 13j
Step 3: 3e (3 words to the right)
Everything else in vim is fast except navigation for me. With mouse, it is a little bit of a pain to move the hand over to the mouse and the click, but still feels orders of magintude faster than jumbling around with line numbers.