You're talking about the greatest feature ever!
 You can use vi commands to edit your shell commands (and command history) by adding this to your .bashrc file:
set -o vi
You can also run that command from the command line to affect only your current session.
If you don't use bash, substitue the appropriate rc file for your shell.
This allows you to use vi commands to edit any command...
You can also use j and k to move through your history (after pressing ESC).
You can also use / (after hitting ESC) to search for old commands.
 In other words, to find that super-long cp command you did ten minutes ago:
ESC/cpENTER
Then you can cycle through all the matching commands in your history with n and N.
All this makes me 10 trillion times more productive at the command line!
 
                