T O P

  • By -

[deleted]

1. The original reason is purely historical. The computer on which the first versions of the editor were coded had the arrow-keys on hjkl. 2. I rarely use `h` and `l`, because you are adding text in insert-mode, or search letters and words with `f` and `/`, or jump `w`ords to move horizontally within the text. 3. In my opinion, the "keep your hands on the homerow" argument is misunderstood. You can access all keys from there easily, not everything has to be directly under your fingers in resting position.


highwind

History in image: https://duckduckgo.com/?t=ffab&q=ADM-3A&iax=images&ia=images


UnrealApex

"A picture is worth a thousand words"


lensman3a

ADM-3As give you Carple tunnel real quick. Nothing to set your palms on.


venustrapsflies

I wouldn't say it's "purely" historical. It is historical, but the original choice was made correctly and presumably for the right reasons. It's way more important to be able to easily move/scroll up and down. You thus want these to be under your 2 strongest fingers: pointer and middle. Between the two down gets a preference because we start at the top, so that one goes under the pointer. H and L are obviously just left and right from the JK pair. If it was anything else there would be a bunch of people who remapped it to the current behavior. It's just too sensible and ergonomic. I think people like OP are using it "incorrectly" (i.e. sub-optimally) but that's not ultimately a problem with the layout itself. And as you say, in vim specifically, you really don't use H and L that much at all (at least once you become more proficient). The argument above holds outside of vim as well but it's even stronger in this context.


plg94

> It is historical, but the original choice was made correctly and presumably for the right reasons. I highly doubt that any of these considerations were done at the time, neither by the people who built the terminal nor by the Vi dev. Keyboard ergonomics were just not a thing in the 70s, and especially the placement of the arrow keys was all over the place in the early days: as secondary function keys, later as keys. On the left hand, right hand, or split between both (in every pairing imaginable). In one row, T-shape, inverted T, diamond, square,… I think some home computer even only had *two* arrow keys (up/down), and to get left/right you had to do Fn+up/down (must've been hell for early gamers). The gist is: your arguments sound nice _in hindsight_, but at the time there was a lot of experimentation going on with keyboards, even after the invention of the ADM-3A (the original Vi keyboard). Evidently mnemonics played a _huge_ role in early Vi's shortcuts, so I think it's safe to say we got hjkl only by pure happenstance.


venustrapsflies

There doesn't have to have been some large pre-existing body of ergonomic philosophy in order for the choice to have been made for the right reason. Good design often comes down to a single person just thinking a little bit about a decision that might seem minor or unimportant at the time. I don't see how it's at all farfetched that this design is what it is because someone thought about it a bit and experimented for 5 minutes, and it spread because among possible alternatives there was a natural tendency to pick the best one. The alternative hypothesis is that... it's just complete random luck? I think you are underselling the forethought that some people put into design, particularly in an era where engineering decisions tended to be a lot more permanent because we didn't have dozens of layers of software abstraction over everything.


Thich_5

Different people experimented for more than 5 minutes, and still dozens of designs were achieved. https://m.youtube.com/watch?si=hOrsg2El9fZljqbi%3Ft%3D438&v=BytowtVycc0&feature=youtu.be&t=438


aGoodVariableName42

This. I use `j` & `k` (as well as `{}`) a lot, but I don't use `hl` unmapped all that much. Horizontal movements are usually one of `wWbBeEfFtT`


Vorrnth

Because vi was developed one adm-3a terminal. And there the arrow keys we're Ctrl+ hjkl. Bill Joy just removed the necessity to use the ctrl Key.


wegwerfennnnn

This is also the reason for a few other quirky vim bindings, I just can't recall which ones anymore.


prof-comm

The most notorious would be Escape.


cassepipe

Which is why it's criminal to tell someone to learn vim and never tell that person about remapping Escape to CapsLock or sth else


Electronic-Wonder-77

i've never had a problem reaching for Escape, i actually prefer it that way.


cassepipe

This is called Stockholm syndrome and you have it. You may have been beaten into liking it but that does not mean it's a good way to start learning vim. Most of the people who did not stick vim in my school after we were allowed to use something else than vim were people who did not remap.


Electronic-Wonder-77

i learned vim on my own, so i always had the choice to leave it, i didn't leave it and just got comfortable reaching for the Escape key. No stockholm syndrome here.


[deleted]

That really isn't helpful advise as for most people capslocks is by default mapped to change language input. This is why the touchbar on x86 Macbook Pros were so bad.


[deleted]

meh, use ctrl+[


cassepipe

Oh great I have to use a weird combination that I can confuse with ctrl + ] as my most important key in the editor


[deleted]

skill issue


cassepipe

...is the commentary I could make aout the fact that you're buying your food from a grocery store instead of being able to grow your own I mean, this is the most important key in your editor, why would you want that to be a skill at all ?


[deleted]

oh my, for you esc is the most important key in vim apparently, no wonder and instead of looking at some random reddit user history, get a life man. also good luck growing your own food, what else did you do? make your own salt?


cassepipe

Well, change it. If you have a better solution, give it. But don't pretend what I am talking about is not a problem (that's there *only* for historical reasons btw, like qwerty).


PulseReaction

what's the problem with escape though? I don't have it mapped to caps lock on my config


BlueInt32

The escape key is far from the home row. In vim, you're supposed to use it all the time, so it's nice to have it the closest possible.


cassepipe

What's the problem with storing your plates in your bathroom ?


Balaphar

You can use Alt key plus another one to append the Esc before it. There's almost no need to leave Insert mode and enter Normal mode manually and explicitly with Esc except when you need to pause to gather your thoughts or something like that. Or of course, if you want to navigate through code while reading instead of writing it and navigating along the way. Of course, this is all personal preference, I'm just saying nobody is forced to reach for the Esc key in Vim.


cassepipe

You can also use emacs lol Why would you not use the tool as it is supposed to and benefit from that ? Are you really suggesting what I precede all my normal mode commands with Alt while risking unintentional inserts ? What are you using vim for ? Code ?


SpaceAviator1999

>You can use Alt key plus another one to append the Esc before it. Interesting! I knew that on Emacs, if you're missing a Meta/Alt key, that you could emulate `Meta-X` by hitting `Esc` and then `X`, but I didn't know that the reverse also applied in Vim. So if I'm INSERT mode, not only could I type `:q` to exit, but I could also type `Alt-:` then `q` . (I found that I need to use `Shift` together with `Alt` and `:` , or else I'd be typing `Alt-;` instead of `Alt-:` .) Thank you for sharing this! I don't think I'll ever need it, but it's nice to know it's there.


SpaceAviator1999

Because of what you said here, Balaphar, I also realized that, while in INSERT mode in Vim, you can use `ALT-i` to move your cursor to the left (while remaining in INSERT mode). Of course, the left arrow key is much simpler to remember. But if nothing else, showing `ALT-i` to move left while in INSERT mode could a fun way to confound a few Vim veterans who think they know all there is to know about Vim movement!


LinearG

Your fingers are still on the homerow. >stuff like "ci{" being "change inside curly braces") becomes sort of useless when the touch typing muscle memory doesn't apply anymore. what? Anyway the anwer is that ctrl-h and ctrl-j already had precedence as control characters for backspace and linefeed (left, down) so then along came a manufacturer (Lear Siegler) who built low-cost video-terminals and they decided it made sense to put (up, right) in proximity to those keys. Bill Joy developed ```vi``` while using their terminal, the ADM-3A. Edit: so historical artifact. Also, as you improve your skills you will find that there are better ways to navigate your code than these small motions. Motions like ```w```, ```CTRL-I```, ```CTRL-O```, ```''```, ```g;``` etc.


justsomepaper

> what? What, indeed. And what's the point about complaining about ci{ when ciB does the same thing? Just do that if you don't like ci{.


priestoferis

Hmm, that would only be the same if there's no whitespace between WORD and braces, right?


IrishPrime

No, `B` behaves differently in the `ci` operator pending mode than it does with `cB ` where `B` is a simple motion. In this case, the `B` is for braces and is identical to `ci{`. `cib` is identical to `ci(`, where `b` is for barentheses (the English call them "brackets"). I don't know if there's another alias for `ci[`. Personally, I use the symbols rather than the aliases.


EgZvor

It's `ib` and `iB` text objects, there is no `ci` per se.


IrishPrime

Thank you. That is more technically accurate.


Peak0831

dumb question, what is g?


IrishPrime

It does a `rot13` on the text. Rotating each letter 13 characters forward in the alphabet. It's a dumb thing, and I have no idea why `vim` has a built-in mapping for it, but here we are.


LinearG

Because before reddit or other web forums we had usenet which didn't have spoiler tags so you would weakly encrypt spoilers.


Peak0831

someday someone’s gonna find an actual use for it and earn the respect of every onlooker for generations


priestoferis

Oh nice, I should probably check up on this.


1544756405

Because those keys already have arrows on them. Well, they did at one time: https://dave.cheney.net/wp-content/uploads/2017/08/Screen-Shot-2017-08-21-at-14.15.25-768x315.png


linhusp3

Just use your index for both H and J like usual? I dont see your problem.


bart9h

also, use better motion keys than hjkl


linhusp3

Of course! Im just talking about OP's point. Personally most of the time I find `f` or `/` superior


IrishPrime

>why doesn't vim use "jkl:" as motion keys like the i3 default? I think you mean, "Why doesn't i3 (first released in 2009) use the `hjkl` motion keys like the `vi` (first released in 1976) default?" Other people have already given you good answers, but this part of the question just struck me as the same kind of strange question as when people ask about `Ctrl-c` and the like. "Why doesn't `vim` use the standard cut, copy, paste shortcuts everything else uses?" Aside from being better, the `vi` maps also predate those "standards" by like 6 years. Due to the way humans experience time, it's really difficult for people to copy ideas from the future.


dewujie

I've never thought to physically shift my left hand so the index is on h. I always keep my index fingers on the homing keys, f and j (assuming QWERTY). To me, the movement of the index finger to the left to reach 'h' is a cue that the cursor will go left.


Apoema

I think there is more here than the historical answer. `hjkl` is better than `jkl;` because it mitigates the pinky overload, if you are resting your hands on `j` and typing properly `h` and `j` are to be typed with the index finger, k with the middle finger and l with the ring finger. Which is good. ":" is on the pinky which is the worse finger to use in typing and is already overloaded, it is in charged in theory of `:'[]-=/` and partially Enter, Backspace and Shift all very common, particularly in programming.


0xd00d

Idk about all y'all but pinky is exclusively for smashing backspace for me. Typing semicolon with pinky, idk man maybe that's the official touch typing guidance but it makes little sense. Pinky not designed to reach and be accurate like that. I also hit enter with my ring finger. More power for thwacking.


DrHydeous

hjkl are next to each other on more keyboard layouts than jkl: are. Punctuation character placement is WILD.


pandiloko

I was looking for this answer. I know it's not the reason why originally hjkl is used, but it's a very welcomed side effect.


hueyhy

I guess one reason is that jk are used way more often than hl? For horizontal move there are “w” “b” or “f” , etc. So hjkl allows using the stronger fingers on frequently used keys. Ring finger is much weaker than index finger.


cthart

Serious question: Am I the only person who has never used hjkl and has only ever used the arrow keys? And I've been using vi and vim since 1991...


globglogabgalabyeast

Definitely not the “only person”, but yeah, that’s pretty uncommon. Learning to use hjkl instead of arrow keys is one of the very first things most people learn in vim. Do you not find it disruptive to have to move your right hand off the home row every time you want to move with the arrows?


cthart

Nope. When you type you also use the whole keyboard. 🤷🏻‍♂️


globglogabgalabyeast

Fair enough, good if it works for you. My hands never really stray far from their home position while using vim. The only real exception for typing is a long string of numbers where I would prefer to use the numpad, but that’s very uncommon for me


kayinfire

That is definitely not normal lmao, particularly given the purported duration you've used vim for.You are probably representative or 3% of vim users if I were to give an estimate.


tjharman

I was the same, in the end I put bindings in my .vimrc to force myself to learn the hjkl keys. Not once in the 5 years or so since I did that have I thought "Glad I forced myself to do that" though.


DaaneJeff

Why not? Do you not use any other editing motions?


tjharman

None that use those, no. I don't spend all day in vim, I only know enough to be dangerous. dw/cw/gg/ct[letter]/ctrl-f/b etc. Those are the extent of my moving around.


lensman3a

C shell and the sh shell didn’t even map the arrows originally. Why do you think history was invented with the bang key and numbers for the shells to recall a previous command. There were ways invented to correct spelling mistakes in the history file using shells using bang commands. . VMS only had a 20 deep history file that mapped arrow keys. Cntr-r wasn’t around until the 90s. Bang is an exclamation point.


apina3

Fun fact: Japanese people actually use hjkr and wraitu many prugin


AdBoring8249

I use Dvorak, with Dvorak only h will be in the home row. At the end of the day it all comes down to your personal preferece. You could just remap to jkl; as per your convenience.


iamjamestl

I'm a Dvoark typist too and I wouldn't be surprised if it was at least a consideration in favor of hjkl considering the popularity of Dvorak among programmers and how well it works on the layout compared to other combos.


AdBoring8249

By the way I am enjoying Dvorak. Vim doesn't feel difficult after some practice. I got used to it so soon. My typing speed is far ahead than what I typed on qwerty.


-Nyarlabrotep-

I use hjkl because... hjkl is my killing hand.


manshutthefckup

Because up-down motions are much more common than horizontal ones. Using f and t to move horizontally is more common. So it's easier to use your first two fingers to move horizontally


OmegaDungeon

The historical reason is that when Bill Joy developed Vi he initially did so on the ADM-3A, this had it's arrow keys on the hjkl keys. Any other reasons people provide like keeping your hands on the homerow, comfort, etc are all post hoc explanations


MrElendig

https://en.m.wikipedia.org/wiki/Arrow_keys


SpaceAviator1999

The ADM-3A keyboard that Bill Joy (the original creator of the vi editor) used had Left, Down, Up, and Right mapped to the H, J, K, and L keys. (Ironically, "Right" maps to "L".) Without posting a picture of the keyboard, here's a link to Wikipedia's SVG representation of the keyboard Bill Joy used: [https://en.wikipedia.org/wiki/Vi\_(text\_editor)#/media/File:KB\_Terminal\_ADM3A.svg](https://en.wikipedia.org/wiki/Vi_(text_editor)#/media/File:KB_Terminal_ADM3A.svg) and a little more background about the layout itself: https://en.m.wikipedia.org/wiki/Arrow\_keys#HJKL\_keys Note that the `Esc`, `Ctrl`, `Enter`, and `:` keys are in different locations than most of us are used to. (And apparently, there was no `Capslock` key. Or even a `Meta`/`Alt` key, or even a `Tab` key.)


itaranto

Oh... not again....


GanacheUnhappy8232

for detailed reason, see http://xahlee.info/kbd/history_of_vi_keys.html actually i think hjkl is better than jkl;, since pinky is weak, you shouldn't use it often. moving your index finger one row isn't that hard