'What triggers the j-k keys to scroll through prev/next commands and how do I properly get out of this mode (without ctlr-c)?

I've been using zsh for several months now with vi commands. Frequently, the command line seems to "lock up" and become unresponsive to input. I chalked it up to some kind of bug, hit ctrl-c, and moved on.

I finally just figured out that I had somehow entered some special mode that activates the "j" and "k" keys to pull up prev/next commands. I still don't know what makes it activate and why it happens.

So now that I know something is happening and I don't know how, it's getting me annoyed. How do I avoid getting into this mode in the first place and how do I properly escape from it without hitting ctrl-c?



Solution 1:[1]

Most likely, you have the vi editing mode enabled. You can switch to emacs mode via bindkey -e. I don't know how you activated the history feature in vi-mode. My gut feeling is that you went into this by hitting escape, which also could have happen when you hit some cursor movement key, and the terminal was not able to interpret the escape sequence. In any case, setting emacs mode should keep you safe.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user1934428