6 ms·
Presumably h, j, k, l will always get you around in vi?
by savanaly 10y ago
Presumably h, j, k, l will always get you around in vi?
- dwaxe 10y agoj and k behavior may vary depending on your config.
- edanm 10y agoEverything can vary depending on your config, but unless they were explicitly remapped, j and k should pretty much do the same thing everywhere. Have you seen somewhere where that isn't the case?
- zodiac 10y ago> Have you seen somewhere where that isn't the case? I use the dvorak keyboard layout and used to remap (among other things) j and k in vim, since they were not on the home row for me. I stopped doing that after a while though.
- IshKebab 10y agoYeah but that is so much less usable. Quick, which one is up?
- chongli 10y agok of course. Having said that, experienced vi/vim users rarely use jk to get around. Instead we use { } / f etc.
- Asooka 10y ago{ } are kind of useless if your coding style puts braces on the same line as the function header.
- Someone 10y agoJust look at your keyboard :-) (https://en.m.wikipedia.org/wiki/ADM-3A#Legacy https://en.m.wikipedia.org/wiki/ADM-3A#Legacy) I always try to remember them by noting that the leftmost key moves left, the rightmost key moves right (not too hard), and that 'K climbs' (using alliteration to remember that). That leaves 'J' for cursor down. In practice, though, I use the cursor keys. Luckily, they work on the editors/systems I work on nowadays. Side effect is that I am very bad at remembering those mnemonics.
- robgough 10y agoI stole the following from a colleagues `.vimrc` which finally allowed me to learn `hjkl`. Now I forget I have this set, and when I do accidentally use an arrow key it makes me laugh. map <Left> :echo 'damnit!'<cr> map <Right> :echo 'you suck!'<cr> map <Up> :echo 'this is why you fail'<cr> map <Down> :echo 'nooooo!'<cr>
- somethingsimple 10y agoOff-topic: I love your username. See https://news.ycombinator.com/item?id=12068116 https://news.ycombinator.com/item?id=12068116
- repsilat 10y ago> K climbs Lower-case 'k' has an ascender, lower-case 'j' has a descender. https://en.wikipedia.org/wiki/Ascender_(typography) https://en.wikipedia.org/wiki/Ascender_(typography) https://en.wikipedia.org/wiki/Descender https://en.wikipedia.org/wiki/Descender
- dorfsmay 10y agoI know k is up, because I constantly <ESC> k in bash, bit the point of using hjkl is exactly not to know which one is what. You set your finger on the keyboard in home position, now your muscle memory does the rest.
- coldtea 10y ago>I know k is up, because I constantly <ESC> k in bash What is ESC-k supposed to do in Bash?
- tbirdz 10y agoThe poster probably changed his bash to use vi editing mode with set -o vi. In this mode, <ESC>k would put the text of the last command entered back on the prompt.
- dorfsmay 10y agoI do switch deadline to vi mode, since that's the editor I use the most. I'm always surprised by people who are on the vi/vim side of vi/emacs debates but then use the defaults emacs mode in deadline!
- dozzie 10y ago"k", as "k" glyph reaches higher from the two. And conversely, "j" reaches lower, so it moves down.
- IshKebab 10y agoYou're right, that is much more usable than having an up button in the up position with an up arrow on it...
- dozzie 10y agoErm... what? I didn't claim it's more usable (though it is for me). I just provided mnemonics I saw once which I liked, for a question "which k/j moves up and which moves down?".
- asksol 10y agoI use hjkl consistently in vim and in the shell. Just think about how long it takes you to move your fingers to the cursor keys. You should spend some effort getting used to it, as using hjkl means you can keep your hands in the middle of the keyboard. I have also never had any problems with strain, and I suspect this is part of the reason.
- daveguy 10y agoThe point is, they are no longer in symbolic memory. At this point they are muscle memory. Quick, which muscle do you use to move your right thumb in? Does it matter?
- cantrevealname 10y agoExactly: muscle memory. In your car, do you move the turn signal lever up or down to indicate a right turn? It actually takes longer to answer this question than to do the action in real life. Another example: There are several passwords that I can type instantly, but I wouldn't be able to recite them.
- fennecfoxen 10y ago> In your car, do you move the turn signal lever up or down to indicate a right turn? You rotate it the same direction you're about to rotate the wheel. The vi navigation keys have no such convenient correspondence.
- JetSpiegel 10y agoThe J kinda looks like an arrow pointing down. If you squint.
- somethingsimple 10y agoI also like what Someone (literally their username, lol) pointed out on another comment, that you can think of K as "klimb" to move up.
- tubs 10y agoh is left because it is on the left of the movement keys, l is right because it is on the right of the movement keys... a fairly convenient correspondence.
- __s 10y agoJust have to imagine the motion. I remember left/right by literally right clicking & feeling my middle finger be to the right of my index. I got a little mixed up when I switched my mouse to my left hand
- rzzzt 10y ago'k' is up, because the author is typing quite a few of it in the screencast before going up. :)
- jholman 10y agoThe leftmost one is left, the rightmost one is right. Of the two that remain, the one that looks vaguely like an arrow pointing downward, that one goes down. There's one key remaining, and that one goes up, k? As everyone says, it doesn't take a lot of practice before you know it well enough that you'll never forget. Unbind the arrow keys, or go play some nethack (no-keypad), or whatever.
- bbcbasic 10y agoI have no idea is a muscle memory thing :-)
- eatbitseveryday 10y agoMiddle finger goes up ;) (K), index down, stretch left to go left (H) or right to go right (L).
- imron 10y agoThe one under my middle finger on my right hand. I don't even have to think, it's automatic. Likewise with the other directions.
- deleted 10y ago[deleted]
- green7ea 10y agoNot in insert mode, it will insert 'h', 'j', 'k' and 'l' ;-)