Hacker News new | ask | show | jobs
by kragen 641 days ago
what's the keystroke sequence to move forward five words, one word at a time (so you don't have to count them first)? in vim it's wwwww, and in emacs it's alt-f f f f f

the asciinema demos are super cool! btw asciinema has an option to record input keystrokes as well as screen output, but i don't know if there's a way to display them in the standard js web player for it

3 comments

I tried but couldn't figure it out from the docs. It's unclear if the selection mode is sticky or is required before each command. e.g. wl would be "next word". I don't know if the command is "wl wl wl wl wl" or "wl l l l l" or if there's a "repeat movement" command.

Update: I installed it and the selection mode is sticky. The command is "wl l l l l"

so sometimes it's just l l l l l, but other times that does a different movement, depending on what mode you're in? how many different things can l l l l l do? are there situations where two of them look the same so you might continue to believe you are in a different mode than you are?

this kind of thing might be a good ux tradeoff but I think you'd have to validate it empirically to see how much the extra cognitive load slows user task completion

Yes, but there’s a visual indicator what the selection mode is, which helped in my brief experimentation.
Selection modes are sticky, so it would be “w l l l l l”
> in vim it's wwwww

You may also want to try out <num><action> methods while in normal mode.

    # Move forward 5 words
    5w

    # Move 20 lines up
    20k
The latter paired with relative line numbering can be really handy.
yeah, that's why i said 'so i don't have to count them first' (the reason i have a computer is so it can count things for me) and used words rather than lines. i agree that relative line numbering is a big plus here
I am a vim user and I wonder what is the use of going five words forward when you can just search for the beginning of the word you want to go to and press enter (even works across lines).

After using vim for a while now I do most of my navigation and editing by searching/replacing

yes, usually it's better to do a search in both vim and emacs, unless you're recording a keyboard macro or using multiple cursors. commonly in the macro or multicursor case, the search string would be different on every line you're trying to make the edit on
I wouldn't say either is better "usually", it really depends on the situation.

If the next five words begin with the same prefix (happens to me), searching will be wasteful. Just spamming "w" is easier.

But when there's something really distinctive (often, punctuation) near the position I'm aiming for, I'll definitely use search.

That's one of the reasons I prefer BRE over ERE/PCRE when editing text interactively - I can search for punctuation in code without having to backslash-escape it.

you have some good points

'bre vs. ere' is terminology i wasn't familiar with, though i've often tripped over the differences: https://www.gnu.org/software/sed/manual/html_node/BRE-vs-ERE...

iirc mit teco used control characters for its regexp metacharacters to diminish this particular problem