vim-mnemonics for hjkl.

371 views
Skip to first unread message

hongy...@gmail.com

unread,
Mar 2, 2021, 5:14:29 AM3/2/21
to vim_use

I noticed the following mnemonics for vim shortcut keys from <https://gist.github.com/iambrj/1e4de522ef5dcf13f530bb4b58cd9b32>:

<quote>

h: left

j: down

k: up

l: right

</quote>

But I still can't figure out the correspondence between their literal representation and the operations of them. Any hints will be highly appreciated.


Regards,

HY

Marius Gedminas

unread,
Mar 2, 2021, 5:31:13 AM3/2/21
to hongy...@gmail.com, vim_use
Take a look at the keyboard layout picture at
https://en.wikipedia.org/wiki/ADM-3A#Hardware
That's the machine on which the Vi editor was created.

(Disappointingly there's no actual photo on Wikipedia, but you can find
those on Google Images.)

On today's machines (using QWERTY layouts) I find it easiest to remember
that h is all the way on the left, j extends down below the baseline, k
extends up beyond the x-height of small letters, and l is all the way on
the right.

Marius Gedminas
--
There is nothing more practical than a good theory.
-- James Clerk Maxwell
signature.asc

tu...@posteo.de

unread,
Mar 2, 2021, 5:37:56 AM3/2/21
to vim...@googlegroups.com
Hi,

that's of a complicated way easy... ;)

on the keyboard the keys are ordered as follows:


H J K L
left right

ok...and J looks a tiny little bit like an arrow downward.

So conclusion is: K must be upward.

HAVE FUN!
Cheers!
mcc
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/63ef0acb-5e0d-403e-8f29-b57c2c10e729n%40googlegroups.com.

Steve Litt

unread,
Mar 2, 2021, 6:08:02 AM3/2/21
to vim...@googlegroups.com
I think it's mostly a matter of ease. It's all done from touch typist
home position, with one hand. Back then there was no mouse, so they
chose the right hand, dominant on the majority of people, as that hand.
I'd guess if mice had existed universally when vi was created, the
cursor keys would have been done by the left hand so the user could
keep his or her right hand on the mouse.

I think the mnemonics were in the fingers, not in the brain.

SteveT

Steve Litt
Autumn 2020 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive

Niels Kobschätzki

unread,
Mar 2, 2021, 8:00:58 AM3/2/21
to vim...@googlegroups.com


Schöne Grüße

Niels

> On 2. Mar 2021, at 12:08, Steve Litt <sl...@troubleshooters.com> wrote:
>
> 
>> On Tue, 2 Mar 2021 02:14:29 -0800 (PST)
>> "hongy...@gmail.com" <hongy...@gmail.com> wrote:
>>
>> I noticed the following mnemonics for vim shortcut keys from
>> <https://gist.github.com/iambrj/1e4de522ef5dcf13f530bb4b58cd9b32>:
>>
>> <quote>
>>
>> h: left
>>
>> j: down
>>
>> k: up
>>
>> l: right
>>
>> </quote>
>>
>> But I still can't figure out the correspondence between their literal
>> representation and the operations of them. Any hints will be highly
>> appreciated.
>
> I think it's mostly a matter of ease. It's all done from touch typist
> home position, with one hand. Back then there was no mouse, so they
> chose the right hand, dominant on the majority of people, as that hand.
> I'd guess if mice had existed universally when vi was created, the
> cursor keys would have been done by the left hand so the user could
> keep his or her right hand on the mouse.
>
> I think the mnemonics were in the fingers, not in the brain.

Iirc the keyboard the original was developed in had even arrow-symbols in hjkl
It is more about the original keyboard than mnemonics or touch typing I think. Same reason for Escape to switch between modes which was on that keyboard where caps lock is today.

Niels

JB

unread,
Mar 2, 2021, 5:12:57 PM3/2/21
to vim...@googlegroups.com
The mnemonic I used for J and K when I first started was J[ump] and K[ite]. H is on the left and L is on the right as pointed out by another user.


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Tony Mechelynck

unread,
Mar 3, 2021, 7:16:50 AM3/3/21
to vim_use
On Tue, Mar 2, 2021 at 11:12 PM 'JB' via vim_use
<vim...@googlegroups.com> wrote:
>
> The mnemonic I used for J and K when I first started was J[ump] and K[ite]. H is on the left and L is on the right as pointed out by another user.
>
>
> Sent with ProtonMail Secure Email.
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Tuesday, March 2, 2021 2:14 AM, hongy...@gmail.com <hongy...@gmail.com> wrote:
>
> I noticed the following mnemonics for vim shortcut keys from <https://gist.github.com/iambrj/1e4de522ef5dcf13f530bb4b58cd9b32>:
>
> <quote>
>
> h: left
>
> j: down
>
> k: up
>
> l: right
>
> </quote>
>
>
>
> But I still can't figure out the correspondence between their literal representation and the operations of them. Any hints will be highly appreciated.
>
>
> Regards,
>
> HY

As others pointed out, whatever memory trick works for you, use it.
With the h j k l keys near the middle of the most used Latin keyboard
layouts, not only QWERTY but also AZERTY and QWERTZ, h is the leftmost
of them and l the rightmost. For the other two, what I use is this:
lowercase j has a downward-pointing tail and lowercase k has an
upward-pointing one.

Also, now that all keyboards have arrow keys, Vim supports them; but
this means that in Normal mode, j and ↓, k and ↑ are synonymous. I
defined the following mappings to have ↓ and ↑ move by screen lines
while j and k move by file lines (which is different when 'wrap' is
on):

" move by screen lines with ↑ ↓, by file lines (Vim default) with k j
" but not in Insert mode, where hjkl insert a letter
:map <Up> gk
:map <Down> gj

Best regards,
Tony.

Csaba Hoch

unread,
Mar 4, 2021, 2:39:31 AM3/4/21
to vim_use
Some years ago I read a mnemonic from the perspective of Japan:

                Kamchatka
                    ^
                    |
    Hong Kong  <----o -----> Los Angeles
                    |
                    V
                Java/Jakarta

Maybe not all four place names were exactly these.

I thought I read it in the Vim documentation, but I cannot find it either there or on the web.

Csaba

Eli the Bearded

unread,
Mar 4, 2021, 1:21:38 PM3/4/21
to vim_use
Csaba Hoch wrote:
> Some years ago I read a mnemonic from the perspective of Japan:
>
> Kamchatka
> ^
> |
> Hong Kong <----o -----> Los Angeles
> |
> V
> Java/Jakarta

That is the funniest memory trick for that I've ever seen.

> Maybe not all four place names were exactly these.
>
> I thought I read it in the Vim documentation, but I cannot find it either
> there or on the web.

I have never seen any use-a-world-map mnemonic tricks for vi / vim
before. It really is very where-you-are centric. For me, Jakarta and
Hong Kong are roughly the same direction, and Los Angeles is south.
Kamchatka is very much north-west instead of north. I could substitute
Klondike, Alaska, and Jalisco, Mexico for north / south. Maybe Lithuania
for east. Hong Kong works fine for west, even though it is really
south-west.

Elijah

joh...@nacs.net

unread,
Mar 4, 2021, 4:15:48 PM3/4/21
to vim...@googlegroups.com
On Tue, Mar 02, 2021 at 02:14:29AM -0800, hongy...@gmail.com wrote:
>
>
The big advantage of hjkl navigation is that it leverages
the home keys for touch typing on a QWERTY keyboard for
what is for many people the dominant right hand. Under
this system and with right hand at the home key positions:

index finger (j)umps down,
middle finger (k)limbs ups,
slide index finger left and (h)urtle left--(h) hangs near (j),
ringer finger to (l)eft of middle finger (l)urches left

Others have already said that "j" looks a bit like an
arrow down symbol, so I used to use this to remind myself
when it was new to me.

Honestly for me, the big reason I learned to rely on hjkl
navigation, had naught to do with being an old-timer
before marked arrow keys and everything to do with playing
Roguelike games such as Angband and UMoria using the
roguelike key command set:
https://rephial.org/help/playing
In such games the arrow keys work, but it saves time not
needing to reach for the arrow keys then hunt and peck for
the letter keys. Essentially, this is the same reason to
use hjkl navigation for text editing.

There is certain elegance to being able to call legacy
game play "training" with a modicum of seriousness. :)

Reply all
Reply to author
Forward
0 new messages