Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #1458 - Accelerated motion

Created: January 6, 2007 12:29 Complexity: basic Author: sply Version: 5.7 Karma: -7/33 Imported from: Tip#1458

noremap L llll
noramap H hhhh


and maybe

noremap J jjjj
noremap K kkkk


Yes, old meaning of H,J,K,L has been changed. Now when you are moving around your text, press Shift to get the cursor accelerated.


Or use acceleration (repeat l,h,j,k in the mappings) to your taste. I used 10x acceleration, but than slowed it down till 4x.

Comments

No comment on the tip, but the title is dumb - I saw the word "steroid" and immediately dismissed it as spam. Only after a few days and noticing it was still in the rss feed did I realise it wasn't.

Anonymous , January 9, 2007 20:52


I agree with sply. If you use 'w' or 'b', the cursor jumps unevenly, so you must: a) press it somewhat slowly as your eye tracks where the cursor moves with each press, or b) count (or estimate) the number of words to jump, press the key sequence, then correct any mistake you made. Another option is to use 'f<char>' (followed by ';'), but this is a similar case: c) find a character close to where you want to go (e.g. h), press 'fh', and keep pressing ';' until you get close by.

All three options require the eye to actively track the cursor and/or the mind to count words. However, if you just hold down 'l' (or in this tip's case, 'L'), you needn't think about it. The cursor moves at a steady pace, so the eye (and mind) can estimate the destination based on timing. This is not possible using 'w', since it does NOT move steadily.

roy , January 9, 2007 8:20


Don't forget the '|' to move to a specific column.

Anonymous , January 19, 2007 7:24


Why not use something like:

map <c-up> 5k map <c-down> 5j

which map Control-up-arrow and Control-down-arrow. On my system <c-left> and <c-right> do not need to be mapped because they already map to previous and next word.

vi2003--AT--zonnet.nl , January 9, 2007 6:49


a. You could have written :noremap L 4l etc. b. what's wrong with w, b, f<char> or t<char> plus a number?

jeehannes--AT--hotmail.com , January 6, 2007 14:32


> a. You could have written :noremap L 4l etc. Yes, that's my error

> b. what's wrong with w, b, f<char> or t<char> plus a number? There is a frequent case when you need to move a cursor from the start of a line somewhere closer to middle of the line.

You can spend 1-2 seconds to count words or symbols number for w/f<char> plus a number. You can spend those 1-2 seconds pressing/releasing w and checking if you've reached the desired position (same with f<char> ;). Or you can press_and_hold l to move cursor on left and release it when you'll be close to that position, yes, again 1-2 seconds.

But when you've pressed 'l', than you can press Shift ('l' is changing to 'L' eq. to '4l') and the cursor accelerates. You hold it a bit and release it when the cursor is close from the destination. When Shift is released, the cursor slows down so you can release 'l' right on the place you wanted. And the total time to move the cursor on the right position takes about two/three times less.

It's a kind of psychomotoric adaptation, when your brain learn the speed, delays and that is able to predict the cursor movement and keypresses delay required to gain the final position. Becouse the cursor's speed is linear instead of random length steps for w,b,f. Those are fine for a short movements (<15-20 chars) or an easy recognized words borders, but for longer distances you has to spend to more time to check where is the cursor after first move, than after second, check if it's on final position... for that case the plain linear movement works better.

, of , when

sply--AT--sply.org , January 6, 2007 15:37


When you want to move closer to the middle of a line, you have the built-in normal mode command gm

Anonymous , January 6, 2007 19:45


How do you join lines when you have mapped J

Anonymous , January 6, 2007 19:46


For line join - personally I have only H, L remapped, when J and K are left to their defaults.


sply , January 7, 2007 3:00


Within the line you�re on, w/b/e are at least as fast but also more precise.

For any larger distances you should use search to hop there instantly instead of skiing the cursor across the text one line at a time.

Of course if these mappings suit you, that�s fine, but it�s just not a very efficient way to move around.

pagaltzis--AT--gmx.de , January 7, 2007 17:32


Advertisement