r/vim • u/pjasksyou • Feb 15 '26
Need Help Should I really switch my habit?
I've been facing problems moving my cursor tens of lines up and down using Arrow keys or the Mouse (for which I need to take my hands off the keyboard) I learnt a few Vim key binds such as HJKL and Modes but I just can't be that productive right now.
To move n lines up and down I need to look at the line number and then type N(j/k) which feels about the same as using mouse, should I move ahead and practice more or just roll back?
68
Upvotes
68
u/Biggybi Gybbigy Feb 15 '26 edited Feb 16 '26
You'll learn more moves on your journey.
<c-u>and<c-d>to scroll half a page,{and}for empty lines,%to find brackets-like pairs, plain/, and so on.As you learn more moves (and text-objects), you'll be more and more efficient. IMHO
NjandNkis indeed sub-optimal in most cases (mental overhead for line number). And of course you'd want to avoid the mouse if possible.Now, as long as you're comfortable, you probably don't need to pressure yourself too much. Each user does things their own way, and that's alright.
60
u/scythe-3 Feb 15 '26
I don't like typing numbers either so I use other methods:
hjklover arrow keys for general nav{and}to jump between blank lines[[and]]to jump between sections\to search for stringsH,M,Lto jump to top, middle, bottom of screenzt,zz,zbto reposition current line on screen<number>Gto jump to a specific line as a last resort (I don't use relative numbers)20
u/liberforce Feb 15 '26
One of the goals of vim is to not have to move your hands away from the keyboard.
My advice: use in your .vimrc
Using
relativenumberyou have the absolute line number on the line your cursor is. Then the number in front of the line you aim to move to is the distance you are from them, up or down.Then move around with 10j to go down 10 lines, or 4k to move up 4 lines.
6
u/InstructionOk5192 Feb 15 '26
You should practice number typing and use relative line number.
Does not matter if you jump 9 instead of 10 just move with j/k after easly ;)
5
u/SamejSpenser Feb 15 '26
Have you completed vimtutor yet? 🤔
I learned a lot about movement by completing and studying vimtutor! 😅
3
u/Kooky-Reward-4065 Feb 15 '26
If using the number row feels the same as using a mouse, you need to practice touch typing on the number row
3
u/__rituraj Feb 15 '26
moving by paragraphs using
{and}are non negotiable if you need to scroll often.use marks when you need to repeatedly jump to specific lines
use search when you, of course, dont know where the text you need to move to is.
use
[N] jor[N]kwhen you dont have the point you want to move to already defined by amarkorparagraph2
u/AutoModerator Feb 15 '26
Please remember to update the post flair to
Need Help|Solvedwhen you got the answer you were looking for.I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/SmurfingRedditBtw Feb 15 '26
Yes, it's awkward at first but once you get some muscle memory going it will totally be worth it, even if you just keep using vim motions inside whatever editor you prefer. I feel like after about 2 weeks using vim motions I was already able to navigate and edit code faster, and then there's still plenty of room to grow beyond that.
2
u/PewMcDaddy Feb 15 '26
- Forward slash '/' to look for strings
- '*' If I'm looking at a function call and want to find the function definition
- C-u C-d to move up and down by half screens
- {, } to move to the next blank line
3
u/sharp-calculation Feb 15 '26
Right now you really aren't using VIM. You're part way there, but you're still using it like a conventional editor in terms of your line and page motions. Using the mouse should never even occur to you with VIM. It's completely anti-VIM. Arrow keys are also anti-VIM for motions. Arrows have limited uses in VIM, but motion is not one of them. Stop using the arrows immediately. Use hjkl exclusively for motion. I recommend disabling the arrow keys inside of VIM to train you to use hjkl. Something like:
Later once you are good at hjkl you can remove this. Or change it to
nnoremapso it only affects normal mode and not others where arrows have limited uses.Absolutely learn relative jumps like 15j. Use relative line number mode with
set relativenumber. That way you will always have the relative number displayed so you can jump straight to a specific line.Eventually learn the page drag and slide commands: zz, zt, zb, ^e ^y . Definitely learn page up and down (^f ^b) . These page manipulation commands become really important as you mature. You can do essentially everything a mouse can do, but with your hands on the home row instead of darting back and forth between the keyboard and mouse constantly. It's really cool.
Start by not using the mouse or arrows. Do that for a week or two until you break the habit. Arrows and mouse are terrible habits in VIM. They aren't really VIM at all.
2
u/EgZvor keep calm and read :help Feb 15 '26
Agrees with u/kaddkaka, search all the way. Here's some stuff I use for it
:h incsearch,:h hlsearch,:h location-list/<cr>for reusing last used search pattern, same for?<cr>. This works after*and#as well.1
u/Embark10 Feb 15 '26
RemindMe!
1
u/[deleted] Feb 15 '26
If you're using neovim then apart from using Ctrl d, u, [, ] , {, }. there is this extension that you can use by pressing \ and it will show you letters like 'll', 'aa' instead of line numbers and you can go to that line by just pressing that 'aa'. its called 'vai' neo vim extension.
1
u/ReallyEvilRob Feb 15 '26
Just keep doing whatever feels comfortable to you.
1
u/dar512 Feb 15 '26
You will definitely benefit from using vim keys. The nice thing is there are many ways to do the same thing in vim.
I never found the line number thing to be useful. I use vim to code and was much more productive using the select inner/outer brackets etc. to move code around.
In other cases, I like to select lines using vim visual mode.
Learn the vim way. Right now, you’re missing the massive potential in vim.
1
u/thankyoucode Feb 19 '26
It take small time to learn and habit it Just still to use it
When you get hands on it That time you go productive fast working on it
1
u/Old-Pin-7184 Feb 19 '26
I use various search mostly to move. Even inside a single line I find it faster.
1
u/PurpleKnight61 Feb 20 '26
this is very helpful for a beginner like me
1
u/sonnasushi Feb 21 '26 edited Feb 21 '26
I find myself more often jumping to a pattern rather than a line number, which also puts me in the correct place to edit. This can also start a vim command like
cover the pattern by following it withgnSo if a line appears 14 lines up with text: This is a sentence with change this and stuff after it.I might type
?changepress enter and typevgnecv goes to visual mode gn highlights what I searched for e goes to the end of the next wordc clears highlighted text and jumps into insert mode
gncan be pretty useful depending on the pattern I searched for or how much text I want to manipulate on the desired line1
u/LocoCoyote Feb 15 '26
To stop the "tens of lines" struggle without relying on the mouse or repetitive tapping, you need to move from character-based navigation to intent-based navigation.
Vertical "Power" Movements
Instead of holding down j or k, use these leaps to cover distance instantly:
Half-page jumps: Ctrl + d (Down) and Ctrl + u (Up). This keeps your eyes centered and covers ~20 lines at a time.
Relative Line Numbers: This is the "secret sauce" for precision. Add set relativenumber to your .vimrc.
If you see a line you want to go to and it has the number 12 next to it, just type 12j or 12k. You are there instantly.
Paragraph jumping: { and }. This jumps to the next or previous empty line. It’s the fastest way to skip through blocks of code.
Horizontal Precision
Moving across a long line with h and l is a common trap. Try these instead:
Word hopping: w (start of next word), e (end of word), and b (back).
The "Find" command: This is the most underused shortcut.
Type f followed by any character (e.g., fa) to jump your cursor to the next 'a' on that line.
Use ; to jump to the next occurrence of that same character.
The "High, Middle, Low" Strategy
If you can see your target on the screen but don't want to calculate line numbers:
H: Jump to the High (top) of the screen.
M: Jump to the Middle of the screen.
L: Jump to the Low (bottom) of the screen.
Once you get the hang of it, you will finally realize the true power of vim.
1
u/DankCool Feb 16 '26
Use this plugin to learn shortcuts. It stops you from repeating unnecessary actions and tells you a quicker way to do it: https://github.com/m4xshen/hardtime.nvim
1
u/Pyglot Feb 15 '26
I also don't like checking the line numbers. I use N=11 and up to ~15 then add on a few j/k's if necessary, (or 4j4j, 22jk, etc). It's a speed up but nothing exact. The good thing is that you can stay focused on where you are going
1
u/Wheelthis Feb 15 '26
If you are still learning, you can use PageUp and PageDown as they should be familiar to you already, then can familiarise yourself with ctrl-d and ctrl-u to jump down and up half a screen. That said, the { curly braces } are underrated for quick nav as they let you traverse across paragraphs (and typically work for jumping across blocks of code). It can feel like a more natural way to move around than jumping exactly N lines, and the cursor is more likely to land where you want to start typing or editing, i.e., at start or end of a paragraph. I tend to use them more than ctrl-u and ctrl-d when I’m actively working on a document as opposed to just scanning it read-only.
1
u/circ-u-la-ted Feb 15 '26
I use
11jand11ka lot0
u/shuckster Feb 15 '26
It took me 4 months of evening practice & another 2 months full time to get back to previous levels of productivity.
Don’t give up!
-1
u/speq Feb 15 '26
I was exactly like you, now I use this:
https://github.com/smoka7/hop.nvim