14 ms·
Why was '~' chosen to represent the home directory?
- sdoering 14y agoI 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.
- saddino 14y agoAh yes, I used the baby blue version. Probably my favorite terminal until the HP2621a (which had a great character set, "modern" housing, and nice loud beep). Since I used the line editor to program I only really used HJKL as cursor keys in rogue. :-)
- shmerl 14y agoStill using Sun Unix keyboard with tilde on the right, and no obnoxious Windows keys ;) Control in the middle row on the left is also helpful in order not to stress the pinky.
- wereHamster 14y agoYou can remap keys in modern operating systems. Any sane person will remap capslock to something they use more often (eg. ctrl or alt). Who needs capslock anyway?
- koralatov 14y agoYouTube commenters, and my boss. I haven't managed to break him of the habit of activating Caps Lock, pressing the key for letter he wants capitalised, then deactivating Caps Lock again.
- ygra 14y agoWhy stop him from doing something that works for him?
- rootbear 14y agoI used to think the same way until I suffered neurological damage that affects the sensory nerves in my fingers. Holding down the shift key while I type some all-caps text, like "STUPID_SHOUTY_MACRO_NAME", is uncomfortable, so I now find the caps lock key useful. It would be nice to have it as a control key, but I would want some other way to activate the caps lock function. Maybe a double tap on the shift key, like on the iPhone keypad, would work.
- jlgreco 14y agoI actually find holding shift nicer for STUPIDLY_LONG_MACROS and whatnot since those underscores require shift and don't work with capslock.
- finnw 14y ago
- DelvarWorld 14y ago100+ upvotes for a lmgtfy answer :(
- evincarofautumn 14y agoSometimes people just don’t know how to search for the topic that interests them. Asking the question is the only way they will find the answer. In that case, adding a well-framed presentation of your better-informed search results, along with some links, is actually a net gain. Search engines can now index your answer and ultimately enable fewer questions like this.
- DanBC 14y agoThat wasn't a lmgtfy answer. It was a constructive link to an encyclopaedia article, with a relevant quote from that article, and a relevant image. There were also links to other sources of information. lmgtfy is hateful because it often links to the same search that the asker has previously done, and returns the same not-useful hits. But the answerer doesn't check the returned hits, and just smugly slaps lmgtfy in to "teach" the asker a lesson about searching before asking.
- yeison 14y agoThanks for this post.
- rawland 14y agoWelcome! :-) Actually, I stumbled over that question during my quest of unifying my keyboard-layouts (Mac=Work and Linux=Private) via xmodmap.
- chimeracoder 14y agoIs that even possible? No matter which way I've tried mapping the keys on OS X, something just can't be placed in the right spot on the keyboard - mostly because many uses of CTRL are placed on the equivalent of Mod-4 (the Command key). Unless you're just trying to simulate an Apple keyboard configuration on Linux, that is.
- johnlinvc 14y agoThe ctrl location on that old machine is much more handy. I've changed my caps lock to ctrl for years.
- koralatov 14y agoSame here. I do, however, hate that most keyboards have a `stepped' Caps Lock key, presumably to stop people accidentally activating it when they type an `a'. Thankfully, my laptop doesn't, and neither does my keyboard at home.
- Symmetry 14y agoThe escape key is also in a better place.
- tracker1 14y agoConsidering I started on the early PCs (XT), I'm too used to the CTRL key where it is... I have a real problem on lenovo, and similar keyboards where the Fn key is in the corner. I also discovered, I favor the right shift, which makes a lot of mini/htpc keyboards a pain... the one I am on right now has the shift to the right of the up arrow.
- ck2 14y agoOn a side note, stackexchange is getting pretty impressive. http://stackexchange.com/sites http://stackexchange.com/sites
- deleted 14y ago[deleted]
- Aardwolf 14y agoWhy oh why did the ADM-3A keyboard not use a gamer configuration for its arrow navigation keys. What a noob designed that! He could have gone for wasd or ijkl. But he had to go with hjkl! Anyway, the fact that j looks like a down arrow is a very good thing that makes me remember it and allow me to play nethack.
- koralatov 14y agoEven worse, it didn't use Cherry red switches, and it looked like crap. Where were the bright red LEDs, macro shortcut buttons, and elaborate wrist-rest?!
- Aardwolf 14y agoCherry red, the linear ones? Why not Cherry brown or blue?
- koralatov 14y agoReds appear to be preferred by the hardcore gamers that buy those monstrous gaming keyboards. I think it's because they're lighter, and also because they're linear.
- deleted 14y ago[deleted]
- Symmetry 14y agoRight. Reds are linear better if you're going to be pressing keys and holding them down, as for moving in an FPS. But Browns, are better if you want a single keypress event registered, as for using the keyboard to type.
- jlgreco 14y agoBlues make great "area denial weapons" to keep people out of your office. Typing on cherry blues sounds like someone typing on a regular keyboard very angrily. ;)
- dkhenry 14y agoWhat does the "Rub" key do ?
- shaurz 14y agoDelete a character i.e. "rub out", presumably.
- dkhenry 14y agoIs that a carryover from the typewriter days ?
- bdunbar 14y agoTeletypes, not typewriters, punching out paper tape.
- JoeAltmaier 14y agoANd 'DEL' is 0x7F in ASCII - so it would punch all the holes, the only way to make 1 char punch turn anything to the same thing.
- bdunbar 14y agoHeh. My only brush with that kind of thing was servicing computers that wrote to the paper tape punches we used in the Marines in the early 90s.
- kps 14y agoAnd this is why DEL is properly a forward delete operation: it erases the character under the cursor and advances (the tape) over the next. I blame the VT220 for screwing this up.
- killahpriest 14y agoRubber is the British English word for eraser.
- atuladhar 14y agoI use vim a lot, but as I was reading this, I realized that unless I was in a vim session (or pretended that I was in one), I couldn't remember which of the hjkl keys mapped to which direction.
- grimgrin 14y agoI think playing Crawl a ton is the only reason I remember so well. But playing too much crawl makes me think I can also move diagonally in vim (yubn).
- ebbv 14y agoSo this is what HN has come to eh? Just random trivia links. Cat pictures can't be more than two weeks off.
- juan_juarez 14y agoThe link content is below par for HN but the tangential discussions that come from it make up for it.
- breck 14y agoI disagree. This is a very interesting data point representative of a broader pattern: Why do we use X? Because N years ago, the environment looked like E1, and so X made sense. Then, people got used to X as a convention, and even though our environment changed to E2, we still use X because of network effects. A great way to improve the world is to understand where X came from, understand how E2 differs from E1, and then invent Y to better fit E2. The hard part is that Y needs to be significantly better than X so that you can get people to switch given that X has stronger network effects.
- B-Con 14y agoBadly off-topic, but I found it amusing that the user asking the question was "Lelouch Lamperouge". The juxtaposition of Lelouch and "home" brought that series back into my mind full-force.
- robomartin 14y agoFunny how all roads lead to a discussion of the merits of vi/m. At least some of you now understand that these tools were designed as you see them today because they were dealing with crippled hardware (from today's vantage point). There was no magical study on keystroke efficiency at the inception. They had lemons and made lemonade. Now, quit arguing and get back to reading Facebook! Yup, that's me ducking in the corner.
- stcredzero 14y agoHJKL is madness. It's more proof that "The Inmates are Running the Asylum" when it comes to usability. We programmers are so much more apt at remapping functions to arbitrary inputs/symbols that we continue to put up with things like this, decades after the reason disappears. This is also why we need to make special efforts at understanding non-programmer users.
- alecdbrooks 14y agoI do agree that "we need to make special efforts at understanding non-programmer users." But this isn't a good example since Vim is a specialized editor mostly recommended for programers. If the general-purpose text editors (and word processors) required you to use HJKL, you might have a point. (EDIT: I misunderstood stcredzero's argument. See stcredzero's comment below.) It's also true that functions can be mapped to arbitrary inputs and systems. But I think there's value in learning HJKL rather than remapping them: 1. They're on the home row, giving a slight speed benefit for these commonly used actions. 2. You get used to the movement keys that will be the default in any copy of Vi/m and quite a few other tools. (HJKL, along with WASD and dedicated arrow keys, is probably the most common mapping of left, right, up, and down to keys on a keyboard.)
- stcredzero 14y ago> But this isn't a good example since Vim is a specialized editor mostly recommended for programers. Arrgh. This is an example of why programmers are different, not of a bad interface for ordinary people. Thanks for considering me so daft as to think non-programmers people use VIM.
- randy909 14y agoLooks like it also explains why caret (^) was chosen in regex and vi to mean "beginning of line".
- dbbolton 14y agoSo why was '~' chosen over '^'?
- kragen 14y agoIf I recall correctly, control-^ (i.e. 0x1e, aka control-~) would move the ADM-3A cursor to the "home" location on the screen (i.e. the top left) if sent from the host. If you were talking to a host that was echoing your keystrokes (and maybe if you set a DIP switch for half-duplex mode?) then typing control-^ (aka control-~) would do that too. The terminfo entry seems to confirm this (apt-get source ncurses-term && less +/^adm3a ncurses-5.9/misc/terminfo.src): adm3a|lsi adm3a, OTbs, am, cols#80, lines#24, OTma=^K^P, OTnl=^J, bel=^G, clear=\032$<1/>, cr=^M, cub1=^H, cud1=^J, cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, home=^^, ind=^J, kcub1=^H, kcud1=^J, kcuf1=^L, kcuu1=^K, rs2=^N, I think the speculations about ^ in regexps coming from the same source are misplaced, because I think the ed editor was already using ^ to mean "beginning of line" before there were any CRT terminals. The ADM-3A had direct cursor addressing, as referenced in the "cup" capability in the above terminfo entry, so the "home" feature was, strictly speaking, redundant. As you can see from the simplicity of the terminfo entry (notably its almost complete lack of escape sequences) logic was aggressively minimized in this termainal. I seem to recall from glancing inside the ADM-3As I bought at auction in my childhood that it was built almost entirely out of discrete 7400-series logic, so every extra control character involved adding several chips. In light of this, I suspect that the "home" feature may have been retained for backwards compatibility with something else — maybe the ADM-3? But the ADM-3 terminfo entry doesn't mention "home", so I don't know. More details about the ADM-3A can be found at <http://manx.classiccmp.org/details/11,5618> http://manx.classiccmp.org/details/11,5618>.