12 ms·
I really liked the additional info on the vim-navigation-keys. Really interesting to see, how the design of specific hardware shaped the "how to use" for genera
by sdoering 14y ago
I really liked the additional info on the vim-navigation-keys. Really interesting to see, how the design of specific hardware shaped the "how to use" for generations to come.
I really have my problems, to wrap my head around "hjkl", as there is (imho) no logical mnemonic for the directions. It is sadly just "learn by rote".
- ximeng 14y agoh and l are obvious for left and right as they're on the left and right. Lower case j goes below the baseline, so down, k is solid at the top so up.
- tome 14y agoAnother question: why shift your right hand one place to the left from its normal position on the home row?
- vacri 14y agoThe first answer in the OP gives a pictorial reference for this.
- evincarofautumn 14y agoI would prefer JKL; to HJKL because my index finger typically rests on the J. Then again, I am an Emacs user, so what do I know?
- Osiris 14y agoThis is exactly why I don't use HJKL for navigation in vim. Shifting my fingers causes me to mis-type all the other commands. I end up just using arrows or word navigation.
- jcl 14y agoAs you get more experienced in vim, you learn more powerful ways to jump around horizontally on a line (t/T/f/F, word navigation, incremental search, etc.), so the most common granular cursor movements become down and up -- which conveniently map to the home-row keys under the strongest and second-strongest fingers.
- evincarofautumn 14y agoRight, that makes sense. In Emacs I generally use C-n (next-line) and C-p (previous-line), but for horizontal movement it’s usually thing like M-b (backward-word) and M-f (forward-word), or C-s (isearch-forward) and C-r (isearch-backward). Emacs isn’t really as good at raw text editing as vim, but clearly there is a lot more to Emacs than raw text editing.
- anonymouz 14y agoPut this in your .vimrc: " Disable arrow keys noremap <Up> <nop> noremap <Down> <nop> noremap <Left> <nop> noremap <Right> <nop> You'll have one or two frustrating days, but after that your muscle memory will take care of remembering "hjkl" for you.
- sdoering 14y agoI know, did this at home and started yelling at my laptop shortly after. Got better, am using the keys nowadays, when using vim. But non the less, the logic didn't register with me. (something like clockwise/counter-clockwise, or anything remotely recognizable ;-) )
- martinp 14y agoAnother vote for this method. This is the only way I managed to train myself to use hjkl when I first started learning Vim. I also disabled Home, End, PgUp and PgDown: noremap <home> <nop> noremap <end> <nop> noremap <pageup> <nop> noremap <pagedown> <nop>
- koralatov 14y agoDuly added to my .vimrc, just in case. Cheers!
- SiVal 14y agoEvery keyboard now has a set of hardware arrowkeys sensibly arranged in an inverted-T, where up means up, left means left, etc. Since everyone is used to that arrangement without any mental effort, macho vim types tell you to force yourself to write with your feet basically to show how hardcore you are. They tell you to use your customization ability in .vimrc to block the sensible arrangement in order to force yourself to learn a ridiculous one that has no advantage other than being the one that we old-timers had to learn before there were sensible arrowkeys. I used that arrangement back in the 1980s myself, but when keyboards evolved, so did I. I remapped the movement keys to match the other movement keys (arrowkeys). If you're going to go to the effort of customizing your vim to force yourself to learn a new keyboard arrangement, customize it so that the movement keys are ijkl instead of hjkl, so that both of your sets of arrowkeys are in the same, natural, modern, inverted-T arrangement. Then you don't have to deactivate those real arrowkeys, because there won't be any temptation to use them with the ijkl keys in the same arrangement and easier to reach. "Oh, no!" people half my age will shriek. "Then what happens to the 'i' key? This would be impossible." Just use the now-unused key on the left ('h') for your insert-on-left. Reach left to insert on left. There, easy. Funny how those who insist that YOU should relearn something as fundamental as the entire inverted-T arrowkey structure built into the hardware of every keyboard and used by almost all apps on all platforms including kids' game boxes find relearning a single, arbitrary 'i' key such an insurmountable obstacle to themselves. But what if you have to use a copy of vim on a machine without your customized .vimrc? Sorry, but that's just an argument against ANY useful customization of vim. It's just not a problem, because the real arrowkeys on the keyboard are in the arrangement you're used to using on the ijkl keys. Just use the real arrowkeys temporarily or copy over your .vimrc. I've done it for years. But what about other editors that have a vi mode? What about something like zsh with a vi mode? These things can be remapped to match your .vimrc unless they only offer a couple of keys, in which case they can be treated just like all apps with their own couple of local keyboard shortcuts. Really, if the standard advice is, "You'll have one or two frustrating days, but after that your muscle memory will take care of remembering "hjkl" for you," then you can take your own advice and keep the inverted-T muscle memory you already have for the movement keys and reduce your task to learning a single 'h' key for insertion, and save the next generation from this nonsense. If a 30-yr user of vi like me isn't stuck with the historical accidents of the past, why should new users have to be?
- ars 14y agoMy fingers still remember the Apple II keyboard arrows keys: Left, Right, Down, Up. http://jwvideo.free.fr/ImagesMac/AppleII/Apple%20II%20int%C3%A9rieur%201600.jpg http://jwvideo.free.fr/ImagesMac/AppleII/Apple%20II%20int%C3... I've always thought that was so much better than the inverted T on PC keyboards, since you can press all the keys without moving your fingers - much faster for games.
- yen223 14y agoI also have problems with 'hjkl'. I could never tell which is up and which is down. If it were up to me, the navigation keys would be mapped to WASD instead.
- juan_juarez 14y agoYou could do that if you wanted.
- Xion 14y agoWhen starting vim (any editor, really) you usually begin at the top. So you want to go down first... Oh, this `j` key has an inset to distinguish it from the rest. Surely this means I need to press this one! (You can easily figure out the three other keys from there).
- oneandoneis2 14y agoWhat worked for me was: H & L are left & right - fairly intuitive, leftmost is left, rightmost is right J looks kinda like a down arrow That leaves K, which must be up by process of elimination :)
- lobotryas 14y agoI memorized HJKL thusly: • H and L are leftmost and rightmost keys, therefore they move the cursor left and right respectively • J kind of looks like it's pointing down • This only leaves K as the up arrow (the only remaining choice)
- kennu 14y agoI remember them because Ctrl-J is newline (moves down), and the rest are obvious after that.
- johncoltrane 14y agoLearn other motions instead (eEbBwW/?fFtT and so on). Once you have integrated them in your workflow, you'll wonder why you even got into the trouble to force yourself to use hjkl instead of the arrows.
- gnosis 14y agoThe best way to learn the hjkl movement keys is to play a game like nethack.[1] [1] - https://en.wikipedia.org/wiki/Nethack https://en.wikipedia.org/wiki/Nethack
- koralatov 14y agoSeconded. Remapping the movement keys in Worms Reloaded also helped massively, though did result in me getting completely thrashed for the first twenty or thirty matches I played.
- kibwen 14y agoThis was my thought when I first tried learning Vim, but I quickly realized that my right-hand home row position for roguelikes is one key too far to the left, meaning that I either had to unlearn those years of DCSS or else teach myself how to type all over again. Not to mention the incessant frustration of unintentional jumps, yanks, and undos when all you're trying to do is move diagonally.
- Steuard 14y agoYeah, but I always played with number_pad enabled, so I never picked it up. (And then I wound up being incapable of playing the game sensibly on my laptop, alas: no diagonals.)
- jff 14y agoThat's why you should learn nethack with hjkl, so you'll know about yubn (http://nethackwiki.com/wiki/Yuhjklbn http://nethackwiki.com/wiki/Yuhjklbn)
- deleted 14y ago[deleted]
- nonamegiven 14y agohjkl: just learn them. These four keys are the most basic thing about vim. Yes there doesn't seem to be much to remember them by, but for these at least, there doesn't need to be. Just muscle through it as long as it takes. It won't take long if you're using vim regularly. Soon you won't think about it, you'll just think "up" and you'll be up a line without consciously thinking "... um ... k". There are ways to get around these four: arrow keys, macros, whatever. Don't. Just learn them. Bonus, those keys show up in other vim-like command interfaces, including bash and other shell command line shortcuts. And if you use .inputrc, they'll show up in database and language repls and similar environments. Just learn them.
- DanBC 14y agoI'm surprised no-one has knocked together a tiny "game" to teach hjkl. Display a big arrow, grab an input, make a nice boop noise if it's right and a nasty beep noise (with a graphic flash) if it's wrong. Keep score of how many key presses were right, and average time for each press.
- stuartmemo 14y agoThey have! Although it's not "tiny". http://vim-adventures.com/ http://vim-adventures.com/
- juan_juarez 14y agoThe original Rogue is a pretty tiny game. By modern standards, Nethack and Angband are fairly small as well.
- kps 14y agoTwo of the four are simply the standard ASCII control characters: · Control-H is Back Space: it moves the cursor one position left. · Control-J is Line Feed: it moves the cursor one line down. The other two seem to be arbitrary on the part of the ADM-3A designers, and having Control-L (Form Feed) perform cursor-right rather than clear-screen seems a bit dubious, but given their constraints and the desire to keep all the motions together, it's hard to argue for any different choices.
- agumonkey 14y agoCan't find the source saying hjkl ascii code is a simple bit-shift operation away from tty arrow code.
- Sukotto 14y ago"hjkl", as there is (imho) no logical mnemonic for the directions. left: "h" is leftmost in the group right: "l" is rightmost in the group down: "j" extends down below the baseline up: "k" extends up to the topline
- dllthomas 14y agoI'm no sure how much it'll help, but: h: move left ctrl-h (which is backspace in ASCII): move left a space while doing something j: move down ctrl-j (line feed): move down a space while doing something Unfortunately, this doesn't extend to k (vertical tab) or l (form feed), but... maybe it's helpful? If you need to practice, play robots or nethack...
- cpeterso 14y agoMy mnemonic for J/K is that my index finger (on J) is "pointing down". (I started to write "and my middle finger (on K) is pointing up", but then I realize that an upward-pointing middle finger means something entirely different.. <:)
- chousuke 14y agoI learned to use hjkl(yubn) by playing Crawl on a macbook which doesn't have a numpad so it was impossible to move diagonally otherwise. Nowadays I don't even need to think about using any of those keys for moving around. In fact, I use them in pretty much every application that supports them, including Firefox (with pentadactyl) and less.