I use the command line a lot on my Macs, in particular, I use iTerm2.
When moving left and right in a command the shortcuts I knew about so far were:
|Key (combination)||Moves Cursor…|
|Right Arrow ‘→’||One character right|
|Left Arrow ‘←’||One character left|
|CTRL + a||Beginning of the line|
|CTRL+ e||End of the line|
After adding the following lines to ~/.zshrc, I now can also move left and right per word using ALT-← and ALT-→ respectively:
bindkey "[D" backward-word # ALT-left-arrow ⌥ + ← bindkey "[C" forward-word # ALT-right-arrow ⌥ + →
Especially when moving around in long command lines, this is really convenient & saves a lot of time.
Do you have keyboard shortcuts that you use regularly on the command line (or elsewhere)? I’d love to hear about them!