I’ve been using zsh for about 15 years but despite this I’ve noticed lately I’m pretty inefficient at editing commands in particular, mostly because I don’t have a clue about emacs keybindings. I am however very familiar with vi bindings but my config was never properly setup for zsh, I couldn’t search history like I could in emacs mode and I’ve been blundering along in this state for too long. (turns out it was just because the bindkey’s were not declared after doing bindkey -v to go to vi mode, oops)
Took a little time this weekend to switch to zsh vi mode and polish up my config so I could efficiently navigate. Most of my config is driven through oh my zsh these days, but I found these additions perfect for working with vi bindings:
Type the start of a command and press up/down arrows to cycle through history for that command. I’ve always used Ctrl-P and Ctrl-N for this but the arrow keys and in the above they work roughly the same.
Ctrl-R and start typing any part of a past command to incrementally search through history. Ctrl-F to move the opposite direction.
Ctrl-J to go into vi command mode and start editing. This flows better than Esc, but technically I think Ctrl-[ is also there by default and very close to J, none the less it doesn’t feel quite as easy to hit.